File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/balancer Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -286,21 +286,22 @@ private boolean chooseProxySource() {
286286 // if node group is supported, first try add nodes in the same node group
287287 if (cluster .isNodeGroupAware ()) {
288288 for (StorageGroup loc : reportedBlock .getLocations ()) {
289- if (cluster .isOnSameNodeGroup (loc .getDatanodeInfo (), targetDN )
289+ //loc may throw NullPointerException
290+ if (loc !=null && cluster .isOnSameNodeGroup (loc .getDatanodeInfo (), targetDN )
290291 && addTo (loc )) {
291292 return true ;
292293 }
293294 }
294295 }
295296 // check if there is replica which is on the same rack with the target
296297 for (StorageGroup loc : reportedBlock .getLocations ()) {
297- if (cluster .isOnSameRack (loc .getDatanodeInfo (), targetDN ) && addTo (loc )) {
298+ if (loc != null && cluster .isOnSameRack (loc .getDatanodeInfo (), targetDN ) && addTo (loc )) {
298299 return true ;
299300 }
300301 }
301302 // find out a non-busy replica
302303 for (StorageGroup loc : reportedBlock .getLocations ()) {
303- if (addTo (loc )) {
304+ if (loc != null && addTo (loc )) {
304305 return true ;
305306 }
306307 }
You can’t perform that action at this time.
0 commit comments