Skip to content

Commit

Permalink
[Transactions] Prevent NPE in case of closeAsync() without a successf…
Browse files Browse the repository at this point in the history
…ul execution of startAsync() (apache#10948)

Fixes apache#10947
### Motivation

If the initialisation of TransactionCoordinatorClientImpl is not completed calling closeAsync will result in a NPE.
  • Loading branch information
eolivelli authored and ciaocloud committed Oct 16, 2021
1 parent 46fa3e4 commit bfe6228
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,13 @@ public CompletableFuture<Void> closeAsync() {
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;
Expand Down

0 comments on commit bfe6228

Please sign in to comment.