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

penghui pushed a commit to branch branch-2.8
in repository https://gitbox.apache.org/repos/asf/pulsar.git

commit 0734191f42f7fca638091bb38193d7b7eb31d4b3
Author: Enrico Olivelli <[email protected]>
AuthorDate: Thu Jun 17 12:47:11 2021 +0200

    [Transactions] Prevent NPE in case of closeAsync() without a successful 
execution of startAsync() (#10948)
    
    Fixes #10947
    ### Motivation
    
    If the initialisation of TransactionCoordinatorClientImpl is not completed 
calling closeAsync will result in a NPE.
    
    (cherry picked from commit 3fd1bfda34d3809797d1839b7b8f239426595c7c)
---
 .../impl/transaction/TransactionCoordinatorClientImpl.java   | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git 
a/pulsar-client/src/main/java/org/apache/pulsar/client/impl/transaction/TransactionCoordinatorClientImpl.java
 
b/pulsar-client/src/main/java/org/apache/pulsar/client/impl/transaction/TransactionCoordinatorClientImpl.java
index f6e6b03..8db8054 100644
--- 
a/pulsar-client/src/main/java/org/apache/pulsar/client/impl/transaction/TransactionCoordinatorClientImpl.java
+++ 
b/pulsar-client/src/main/java/org/apache/pulsar/client/impl/transaction/TransactionCoordinatorClientImpl.java
@@ -134,11 +134,13 @@ public class TransactionCoordinatorClientImpl implements 
TransactionCoordinatorC
             LOG.warn("The transaction meta store is closing or closed, doing 
nothing.");
             result.complete(null);
         } else {
-            for (TransactionMetaStoreHandler handler : handlers) {
-                try {
-                    handler.close();
-                } catch (IOException e) {
-                    LOG.warn("Close transaction meta store handler error", e);
+            if (handlers != null) {
+                for (TransactionMetaStoreHandler handler : handlers) {
+                    try {
+                        handler.close();
+                    } catch (IOException e) {
+                        LOG.warn("Close transaction meta store handler error", 
e);
+                    }
                 }
             }
             this.handlers = null;

Reply via email to