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



##########
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:
       > 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.
   
   The read and the write are not in separate threads. They are both scheduled 
to run as runnables on the `executor` in this class. That `executor` has a 
single thread. If the read is in an infinite loop, the `close` runnable will 
_never_ run.




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