Skip to content

Use LinkedHashMap for deterministic iterations#1165

Merged
velo merged 1 commit into
OpenFeign:masterfrom
contextshuffling:branch
Jan 29, 2020
Merged

Use LinkedHashMap for deterministic iterations#1165
velo merged 1 commit into
OpenFeign:masterfrom
contextshuffling:branch

Conversation

@contextshuffling

@contextshuffling contextshuffling commented Jan 28, 2020

Copy link
Copy Markdown
Contributor

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

kortov commented Jan 28, 2020

Copy link
Copy Markdown

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
Copy Markdown
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

kortov commented Jan 29, 2020

Copy link
Copy Markdown

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.

@velo velo left a comment

Copy link
Copy Markdown
Member

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

3 participants