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 @@ void addToBeginning(NodeData node) { /** * 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) {