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

Use LinkedHashMap for deterministic iterations #1165

Merged
merged 1 commit into from Jan 29, 2020

Conversation

contextshuffling
Copy link
Contributor

@contextshuffling contextshuffling commented Jan 28, 2020

Test shouldPrintHeaders() asserts the string version of RequestHeader. RequestHeader class uses a HashMap to store the headers. However, HashMap does not guarantee any specific order of entries. Test can fail if the iteration order changes.
This PR proposes to fix the test by changing HashMap to LinkedHashMap that makes the iteration order deterministic.

@kortov
Copy link

kortov commented Jan 28, 2020

I guess to change implementation for tests is not a good approach. HashMap is lighter than LinkedHashMap ofc. I guess there should be a better approach to test it though I agree on a deterministic approach

@contextshuffling
Copy link
Contributor Author

@kortov Thanks for the feedback. I guess another approach is to assert for both orders. It gets messy when there are more but in this test, there are only two possible cases.

@kortov
Copy link

kortov commented Jan 29, 2020

Maybe you're right with your implementation because in

: new LinkedHashMap<>();
binded LinkedHashMap . And more than that, your PR is to feign.mock package, so I guess performance is not bigger issue than determenistic results.

Copy link
Member

@velo velo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change looks good, will merge as soon build passes

@velo velo added enhancement For recommending new capabilities feedback provided Feedback has been provided to the author ready to merge Will be merged if no other member ask for changes waiting for feedback Issues waiting for a response from either to the author or other maintainers labels Jan 29, 2020
@contextshuffling
Copy link
Contributor Author

@velo I fixed the format issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement For recommending new capabilities feedback provided Feedback has been provided to the author ready to merge Will be merged if no other member ask for changes waiting for feedback Issues waiting for a response from either to the author or other maintainers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants