mattisonchao commented on code in PR #18280:
URL: https://github.com/apache/pulsar/pull/18280#discussion_r1010261577


##########
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/cache/RangeEntryCacheImpl.java:
##########
@@ -201,20 +201,6 @@ public void invalidateAllEntries(long ledgerId) {
     @Override
     public void asyncReadEntry(ReadHandle lh, PositionImpl position, final 
ReadEntryCallback callback,
             final Object ctx) {
-        try {
-            asyncReadEntry0(lh, position, callback, ctx);
-        } catch (Throwable t) {
-            log.warn("failed to read entries for {}-{}", lh.getId(), position, 
t);

Review Comment:
   If `callback.readEntryComplete(cachedEntry, ctx);` throw any exception, the 
exception will also be catched by here, and invoke the 
`callback.readEntryFailed(createManagedLedgerException(t), ctx);`.
   
   This means that in some cases we may call both methods, which is a risk to 
some recycle objects or other states.
   



##########
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/cache/RangeEntryCacheImpl.java:
##########
@@ -201,20 +201,6 @@ public void invalidateAllEntries(long ledgerId) {
     @Override
     public void asyncReadEntry(ReadHandle lh, PositionImpl position, final 
ReadEntryCallback callback,
             final Object ctx) {
-        try {
-            asyncReadEntry0(lh, position, callback, ctx);
-        } catch (Throwable t) {
-            log.warn("failed to read entries for {}-{}", lh.getId(), position, 
t);

Review Comment:
   If `callback.readEntryComplete(cachedEntry, ctx);` throw any exception, the 
exception will also be catched by here, and invoke the 
`callback.readEntryFailed(createManagedLedgerException(t), ctx);`.
   
   This means that in some cases we may call both methods, which is a risk to 
some recycled objects or other states.
   



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