-
Notifications
You must be signed in to change notification settings - Fork 8.8k
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
HADOOP-17009: Embrace Immutability of Java Collections #1974
Conversation
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
...n-project/hadoop-common/src/main/java/org/apache/hadoop/security/CompositeGroupsMapping.java
Outdated
Show resolved
Hide resolved
💔 -1 overall
This message was automatically generated. |
return null; | ||
} | ||
return new ArrayList<Node>(rack.getChildren()); | ||
return (rack == null) ? Collections.emptyList() |
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 can we use unmodifiable here?
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.
Ya, I guess we probably shouldn't. My thinking wsa "
- Returning null is usually a bad idea, return Collections.emptyList()
- Collections.emptyList() is immutable
- To make the method consistent, the list of racks should be immutable too.
I will revert this to return an emptyList (new ArrayList<>(0))
💔 -1 overall
This message was automatically generated. |
Hi~ @goiri |
I wanted to give others a chance to comment. |
@goiri I'm not commiter but the patch LGTM. |
@Cosss7 thanks for the review. |
No description provided.