zymap commented on a change in pull request #12123:
URL: https://github.com/apache/pulsar/pull/12123#discussion_r715309075



##########
File path: 
tiered-storage/jcloud/src/main/java/org/apache/bookkeeper/mledger/offload/jcloud/impl/BlobStoreBackedReadHandleImpl.java
##########
@@ -54,6 +56,15 @@
     private final DataInputStream dataStream;
     private final ExecutorService executor;
 
+    enum State {
+        Opened,
+        Closed
+    }
+
+    private AtomicReferenceFieldUpdater<BlobStoreBackedReadHandleImpl, State> 
STATE_UPDATER = AtomicReferenceFieldUpdater
+        .newUpdater(BlobStoreBackedReadHandleImpl.class, State.class, "state");
+    private volatile State state = null;

Review comment:
       Yes. We did don't need the `AtomicReferenceFieldUpdater` to control it. 
But we need to make it as `volatile`, the read and close in the different 
thread, if the read thread into an infinite loop, then someone triggers the 
close, the read thread can not exit the infinite loop because the state is 
holding by the read thread. We need to add the volatile to make the state can 
be notified when it's changed.




-- 
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]


Reply via email to