HDFS-13155. BlockPlacementPolicyDefault.chooseTargetInOrder Not Checking Return Value for NULL. Contributed by Zsolt Venczel.

(cherry picked from commit bccdfeee0a)
This commit is contained in:
Wei-Chiu Chuang 2018-06-04 07:02:05 -07:00
parent fde45994a3
commit 302c36ffdc
1 changed files with 7 additions and 3 deletions

View File

@ -480,9 +480,13 @@ public class BlockPlacementPolicyDefault extends BlockPlacementPolicy {
throws NotEnoughReplicasException {
final int numOfResults = results.size();
if (numOfResults == 0) {
writer = chooseLocalStorage(writer, excludedNodes, blocksize,
maxNodesPerRack, results, avoidStaleNodes, storageTypes, true)
.getDatanodeDescriptor();
DatanodeStorageInfo storageInfo = chooseLocalStorage(writer,
excludedNodes, blocksize, maxNodesPerRack, results, avoidStaleNodes,
storageTypes, true);
writer = (storageInfo != null) ? storageInfo.getDatanodeDescriptor()
: null;
if (--numOfReplicas == 0) {
return writer;
}