-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue #264: Remove unnecessary calls to freePort
.
#265
Issue #264: Remove unnecessary calls to freePort
.
#265
Conversation
have an unused port, because we want to keep the origin unreachable.
.start(); | ||
|
||
FullHttpResponse response = doGet("/"); | ||
|
||
assertThat(response.status(), is(OK)); | ||
assertThat(response.status().code(), is(OK.code())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was this necessary? If they don't match, it may indicate that the classes are not the same, e.g. Styx HttpResponseStatus
vs Netty HttpResponseStatus
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. Importing now Styx HttpResponseStatus
instead of Netty.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would say some of the freePort() usages previously were actually nicer to work with: e.g., we don't have to
HttpServer server = NettyServerBuilder.newBuilder() | ||
.setHttpConnector(connector(port)) | ||
.setHttpConnector(connector(0)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would say the code is a bit easier to write if we use freeport for the cases with '0' and WireMockServer.dynamic*Port() instead of having to find what's the correct way to get a random port in each case. That doesn't mean we have to keep the 'port' variable used later...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @dvlato. freePort
is problematic because it can easily cause port conflicts in parallel environments. Because it is susceptible for race conditions it should be avoided.
Fixes #264.