Skip to content
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

Merged

Conversation

mikkokar
Copy link
Contributor

@mikkokar mikkokar commented Sep 3, 2018

Fixes #264.

.start();

FullHttpResponse response = doGet("/");

assertThat(response.status(), is(OK));
assertThat(response.status().code(), is(OK.code()));
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

@dvlato dvlato left a 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))
Copy link
Contributor

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...

Copy link
Contributor Author

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.

@mikkokar mikkokar merged commit 2075eff into ExpediaGroup:master Sep 4, 2018
@mikkokar mikkokar deleted the issue-264-remove-calls-to-freePort branch September 4, 2018 07:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants