You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by pe...@apache.org on 2021/06/17 10:49:20 UTC
[pulsar] branch master updated: [Transactions] Prevent NPE in case
of closeAsync() without a successful execution of startAsync() (#10948)
This is an automated email from the ASF dual-hosted git repository.
penghui 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 3fd1bfd [Transactions] Prevent NPE in case of closeAsync() without a successful execution of startAsync() (#10948)
3fd1bfd is described below
commit 3fd1bfda34d3809797d1839b7b8f239426595c7c
Author: Enrico Olivelli <eo...@gmail.com>
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.
---
.../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;