This is an automated email from the ASF dual-hosted git repository.

zike pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar.git


The following commit(s) were added to refs/heads/master by this push:
     new 41a7917ca76 [fix][txn] Fix the incorrect log of Transaction Builder 
(#19357)
41a7917ca76 is described below

commit 41a7917ca762bd4a2329b9ca3cc84d0d00b24daf
Author: Zike Yang <[email protected]>
AuthorDate: Wed Feb 1 09:51:13 2023 +0800

    [fix][txn] Fix the incorrect log of Transaction Builder (#19357)
    
    ### Motivation
    
    If the transaction build fails, the `Success to new txn` still is printed. 
This is an incorrect log and will make users confused.
    
    ### Modifications
    
    * Print success log only if the transaction build successfully.
    
    Signed-off-by: Zike Yang <[email protected]>
    Co-authored-by: Nicolò Boschi <[email protected]>
---
 .../pulsar/client/impl/transaction/TransactionBuilderImpl.java      | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git 
a/pulsar-client/src/main/java/org/apache/pulsar/client/impl/transaction/TransactionBuilderImpl.java
 
b/pulsar-client/src/main/java/org/apache/pulsar/client/impl/transaction/TransactionBuilderImpl.java
index 3da209b5424..c5e9d4781c5 100644
--- 
a/pulsar-client/src/main/java/org/apache/pulsar/client/impl/transaction/TransactionBuilderImpl.java
+++ 
b/pulsar-client/src/main/java/org/apache/pulsar/client/impl/transaction/TransactionBuilderImpl.java
@@ -65,14 +65,14 @@ public class TransactionBuilderImpl implements 
TransactionBuilder {
         transactionCoordinatorClient
                 .newTransactionAsync(txnTimeout, timeUnit)
                 .whenComplete((txnID, throwable) -> {
-                    if (log.isDebugEnabled()) {
-                        log.debug("Success to new txn. txnID: {}", txnID);
-                    }
                     if (throwable != null) {
                         log.error("New transaction error.", throwable);
                         future.completeExceptionally(throwable);
                         return;
                     }
+                    if (log.isDebugEnabled()) {
+                        log.debug("'newTransaction' command completed 
successfully for transaction: {}", txnID);
+                    }
                     TransactionImpl transaction = new TransactionImpl(client, 
timeUnit.toMillis(txnTimeout),
                             txnID.getLeastSigBits(), txnID.getMostSigBits());
                     future.complete(transaction);

Reply via email to