HDFS-13962. Add null check for add-replica pool to avoid lock acquiring. Contributed by Surendra Singh Lilhore.

This commit is contained in:
Yiqun Lin 2018-10-09 10:33:13 +08:00
parent 347ea38581
commit 1043795f7f
2 changed files with 5 additions and 3 deletions

View File

@ -183,8 +183,10 @@ public int compare(File f1, File f2) {
.setConf(conf)
.setInitialUsed(loadDfsUsed())
.build();
// initialize add replica fork join pool
initializeAddReplicaPool(conf);
if (addReplicaThreadPool == null) {
// initialize add replica fork join pool
initializeAddReplicaPool(conf);
}
// Make the dfs usage to be saved during shutdown.
shutdownHook = new Runnable() {
@Override

View File

@ -154,7 +154,7 @@ ReplicaInfo addAndGet(String bpid, ReplicaInfo replicaInfo) {
if (oldReplicaInfo != null) {
return oldReplicaInfo;
} else {
set.add(replicaInfo);
set.addOrReplace(replicaInfo);
}
return replicaInfo;
}