-
Notifications
You must be signed in to change notification settings - Fork 506
[COLLECTIONS-881] MultiMapUtils.getXXX ensure safe copy #669
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
base: master
Are you sure you want to change the base?
[COLLECTIONS-881] MultiMapUtils.getXXX ensure safe copy #669
Conversation
garydgregory
left a comment
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.
| } | ||
|
|
||
| @Test | ||
| void testGetValuesAsBagIsSafeCopy() { |
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.
This test doesn't prove anything about the changes in main because it passes without changes to main.
| } | ||
|
|
||
| @Test | ||
| void testGetValuesAsListIsSafeCopy() { |
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.
OTOH, this test does prove the changes in main matter because it fails without changes to main.
| } | ||
|
|
||
| @Test | ||
| void testGetValuesAsSetIsSafeCopy() { |
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.
This test doesn't prove anything about the changes in main because it passes without changes to main.
2d5dff4 to
5a11203
Compare
|
Thank you for the feedback! I reviewed my test cases and found the issues. However, I couldn't find any |
|
Hi @clapppp
|
5a11203 to
75200cf
Compare
| @Test | ||
| void testGetValuesAsSet() { | ||
| assertNull(MultiMapUtils.getValuesAsList(null, "key1")); | ||
| assertNull(MultiMapUtils.getValuesAsSet(null, "key1")); |
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 corrected a typo.
| } | ||
|
|
||
| @Test | ||
| void testGetValuesAsBagIsSafeCopy() { |
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 added the test case using EasyMock, consistent with the project's existing dependencies.
|
I made the changes as you suggested. |
This PR modifies getXXX method to return new Collection.
Updated getValuesAsSet, getValuesAsList, and getValuesAsBag to always return a new copy.
Added unit tests to verify that returned collections are independent of the backing map.
Updated Javadocs to reflect that a new collection is returned.