You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-issues@hadoop.apache.org by GitBox <gi...@apache.org> on 2020/04/27 13:53:38 UTC

[GitHub] [hadoop] belugabehr commented on a change in pull request #1974: HADOOP-17009: Embrace Immutability of Java Collections

belugabehr commented on a change in pull request #1974:
URL: https://github.com/apache/hadoop/pull/1974#discussion_r415831875



##########
File path: hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NetworkTopology.java
##########
@@ -196,10 +196,8 @@ protected Node getNodeForNetworkLocation(Node node) {
         loc = loc.substring(1);
       }
       InnerNode rack = (InnerNode) clusterMap.getLoc(loc);
-      if (rack == null) {
-        return null;
-      }
-      return new ArrayList<Node>(rack.getChildren());
+      return (rack == null) ? Collections.emptyList()

Review comment:
       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))




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org