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



##########
File path: 
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/CompositeGroupsMapping.java
##########
@@ -78,15 +79,13 @@
             user, provider.getClass().getSimpleName(), e.toString());
         LOG.debug("Stacktrace: ", e);
       }        
-      if (groups != null && ! groups.isEmpty()) {
+      if (!groups.isEmpty()) {
         groupSet.addAll(groups);
         if (!combined) break;
       }
     }
 
-    List<String> results = new ArrayList<String>(groupSet.size());
-    results.addAll(groupSet);
-    return results;
+    return Collections.unmodifiableList(new ArrayList<>(groupSet));

Review comment:
       Now, somebody calling getGroups() would start failing if it was adding 
new things to the list while that was not the case before. I've tried using 
inmodifiable before but is kind of dangerous.




----------------------------------------------------------------
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:
us...@infra.apache.org



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

Reply via email to