浏览代码

HDFS-14843. Double Synchronization in BlockReportLeaseManager. Contributed by David Mollitor.

Inigo Goiri 5 年之前
父节点
当前提交
afa1006a53

+ 2 - 6
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockReportLeaseManager.java

@@ -180,12 +180,8 @@ class BlockReportLeaseManager {
   /**
    * Get the next block report lease ID.  Any number is valid except 0.
    */
-  private synchronized long getNextId() {
-    long id;
-    do {
-      id = nextId++;
-    } while (id == 0);
-    return id;
+  private long getNextId() {
+    return ++nextId == 0L ? ++nextId : nextId;
   }
 
   public synchronized void register(DatanodeDescriptor dn) {