Skip to content

Commit

Permalink
The problem of two exception handling (apache#12744)
Browse files Browse the repository at this point in the history
whenCompleteAsync has handle exception, don't use exceptionally, otherwise it will be handle twice
  • Loading branch information
liangyepianzhou authored and eolivelli committed Nov 29, 2021
1 parent 8f2f880 commit 0f41d1c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -234,12 +234,7 @@ private void asyncReadEntry0(ReadHandle lh, PositionImpl position, final ReadEnt
} finally {
ledgerEntries.close();
}
}, ml.getExecutor().chooseThread(ml.getName())).exceptionally(exception->{
ml.invalidateLedgerHandle(lh);
callback.readEntryFailed(createManagedLedgerException(exception), ctx);
return null;
}
);
}, ml.getExecutor().chooseThread(ml.getName()));
}
}

Expand Down Expand Up @@ -333,17 +328,7 @@ private void asyncReadEntry0(ReadHandle lh, long firstEntry, long lastEntry, boo
} finally {
ledgerEntries.close();
}
}, ml.getExecutor().chooseThread(ml.getName())).exceptionally(exception->{
if (exception instanceof BKException
&& ((BKException)exception).getCode() == BKException.Code.TooManyRequestsException) {
callback.readEntriesFailed(createManagedLedgerException(exception), ctx);
} else {
ml.invalidateLedgerHandle(lh);
ManagedLedgerException mlException = createManagedLedgerException(exception);
callback.readEntriesFailed(mlException, ctx);
}
return null;
});
}, ml.getExecutor().chooseThread(ml.getName()));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,6 @@ public void asyncReadEntry(ReadHandle lh, long firstEntry, long lastEntry, boole
ml.mbean.addReadEntriesSample(entries.size(), totalSize);

callback.readEntriesComplete(entries, ctx);
}).exceptionally(exception -> {
callback.readEntriesFailed(createManagedLedgerException(exception), ctx);
return null;
});
}

Expand Down

0 comments on commit 0f41d1c

Please sign in to comment.