Fix #16998 - to set server.port to -1 only for web application and who doesn't have custom server port. I have the same issue as it, so l'd like to sumbit a PR to fix it.

Comment From: pivotal-issuemaster

@785172550 Please sign the Contributor License Agreement!

Click here to manually synchronize the status of this Pull Request.

See the FAQ for frequently asked questions.

Comment From: pivotal-issuemaster

@785172550 Thank you for signing the Contributor License Agreement!

Comment From: 785172550

When I fix the issue #16998, my IDEA inspected some weakness to improve so I do a second commit BTW

Comment From: philwebb

When I fix the issue #16998, my IDEA inspected some weakness to improve so I do a second commit BTW

Could you please submit those as a second pull-request? Mixing the two things in one PR makes it harder to see the fix. Thanks!

Comment From: 785172550

@philwebb ok will do that

Comment From: 785172550

@philwebb could you take a review of this PR

Comment From: snicoll

@785172550 thanks for the PR but setting server.port to -1 for the embedded use case feels a bit odd since it either should be a defined port or a random port. Setting this to -1 should have no effect as the chosen mode will override the port anyway.

It looks like more we should not set it to -1 at all. Let's resume the conversation on the issue.

Comment From: 785172550

@snicoll yes, I dont know why set it to -1 for all case. And one more thing, @TestPropertySource(properties = "server.port=12345") will overide the server.port while properties file not