You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2023/10/16 15:15:01 UTC

[camel] branch camel-3.x updated: CAMEL-19996 avoid NPE when handling exception without coordinator (#11733)

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

davsclaus pushed a commit to branch camel-3.x
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/camel-3.x by this push:
     new bc61bc87ee5 CAMEL-19996 avoid NPE when handling exception without coordinator (#11733)
bc61bc87ee5 is described below

commit bc61bc87ee55190796c62252c3e2e9c98b4be0bb
Author: Johannes Boßle <jo...@knowis.de>
AuthorDate: Mon Oct 16 17:14:16 2023 +0200

    CAMEL-19996 avoid NPE when handling exception without coordinator (#11733)
    
    Co-authored-by: Johannes Boßle <jb...@knowis.de>
---
 .../java/org/apache/camel/processor/saga/SagaProcessor.java   | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/core/camel-core-processor/src/main/java/org/apache/camel/processor/saga/SagaProcessor.java b/core/camel-core-processor/src/main/java/org/apache/camel/processor/saga/SagaProcessor.java
index 2e0354de516..a9acf56b73f 100644
--- a/core/camel-core-processor/src/main/java/org/apache/camel/processor/saga/SagaProcessor.java
+++ b/core/camel-core-processor/src/main/java/org/apache/camel/processor/saga/SagaProcessor.java
@@ -76,10 +76,15 @@ public abstract class SagaProcessor extends DelegateAsyncProcessor implements Tr
             AsyncCallback callback) {
         if (this.completionMode == SagaCompletionMode.AUTO) {
             if (exchange.getException() != null) {
-                coordinator.compensate().whenComplete((done, ex) -> ifNotException(ex, exchange, callback, () -> {
-                    setCurrentSagaCoordinator(exchange, previousCoordinator);
+                if (coordinator != null) {
+                    coordinator.compensate().whenComplete((done, ex) -> ifNotException(ex, exchange, callback, () -> {
+                        setCurrentSagaCoordinator(exchange, previousCoordinator);
+                        callback.done(false);
+                    }));
+                } else {
+                    // No coordinator available, so no saga available.
                     callback.done(false);
-                }));
+                }
             } else {
                 coordinator.complete().whenComplete((done, ex) -> ifNotException(ex, exchange, callback, () -> {
                     setCurrentSagaCoordinator(exchange, previousCoordinator);