From afa1006a537e1fc1adb5005cbdf4e4d8d9e98b22 Mon Sep 17 00:00:00 2001 From: Inigo Goiri Date: Tue, 24 Sep 2019 09:58:42 -0700 Subject: [PATCH] HDFS-14843. Double Synchronization in BlockReportLeaseManager. Contributed by David Mollitor. --- .../server/blockmanagement/BlockReportLeaseManager.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockReportLeaseManager.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockReportLeaseManager.java index 7db05c7aaa..2a4b6e8455 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockReportLeaseManager.java +++ b/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) {