asafm commented on code in PR #16758:
URL: https://github.com/apache/pulsar/pull/16758#discussion_r943370289


##########
pulsar-transaction/coordinator/src/main/java/org/apache/pulsar/transaction/coordinator/impl/TxnLogBufferedWriter.java:
##########
@@ -210,9 +210,15 @@ public void asyncAddData(T data, AddDataCallback callback, 
Object ctx){
             return;
         }
         singleThreadExecutorForWrite.execute(() -> {
+            int recordsCountBeforeAdd = dataArray.size();
             try {
                 internalAsyncAddData(data, callback, ctx);
             } catch (Exception e){
+                // Avoid missing callback, do failed callback when error occur 
before add data to the array.
+                int recordsCountAfter = dataArray.size();
+                if (recordsCountAfter == recordsCountBeforeAdd){
+                    callback.addFailed(new 
ManagedLedgerException.ManagedLedgerFencedException(e), ctx);

Review Comment:
   I'm not referring to static variable, but to add an import static statement, 
so you can only `new ManagedLedgerFencedException(` without the 
`ManagedLedgerException` prefix.
   
   >No exception is thrown in the block of "try catch". If it does, it will be 
due to coding errors such as data Serializer or metrics.
   I don't understand. You could have chosen RuntimeException or any other 
exception class, why did you specifically choose ManagedLedgerFencedException? 
   @codelipenghui this sound reasonable to you?
   



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