sodonnel commented on a change in pull request #2052: URL: https://github.com/apache/hadoop/pull/2052#discussion_r435068270
########## File path: hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsDatasetImpl.java ########## @@ -578,7 +578,13 @@ public void removeVolumes( // Unlike updating the volumeMap in addVolume(), this operation does // not scan disks. for (String bpid : volumeMap.getBlockPoolList()) { - List<ReplicaInfo> blocks = new ArrayList<>(); + List<ReplicaInfo> blocks; + if (blkToInvalidate.containsKey(bpid)) { + blocks = blkToInvalidate.get(bpid); + } else { + blocks = new ArrayList<>(); + blkToInvalidate.put(bpid, blocks); + } Review comment: If you like, you can change this block to below (Java 8 feature): ``` List<ReplicaInfo> blocks = blkToInvalidate.computeIfAbsent(bpid, (k) -> new ArrayList<>()); ``` This will return the existing key if it exists, or create a new one it does not. ---------------------------------------------------------------- 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