szetszwo commented on code in PR #11724:
URL: https://github.com/apache/ozone/pull/11724#discussion_r4528822449


##########
hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/StreamBlockInputStream.java:
##########
@@ -195,21 +199,19 @@ public int readPositioned(long blockOffset, ByteBuffer 
dst) throws IOException {
     if (!dst.hasRemaining()) {
       return 0;
     }
-    updateBlockLength();
+    // updateBlockLength() sets blockLength before it clears the volatile 
flag, so blockLength is safe to read here.
+    if (needUpdateBlockLength) {
+      updateBlockLength();
+    }

Review Comment:
   @amaliujia Good point!  I missed that this is a double checking lock.  Then, 
let's keep it here and 
   ```java
   // needUpdateBlockLength is volatile. Use a double checking lock to avoid 
synchronization 
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to