You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Johannes Boßle (Jira)" <ji...@apache.org> on 2023/10/16 14:20:00 UTC

[jira] [Created] (CAMEL-19996) camel-lra NullPointerException when creating a saga with invalid lra-url

Johannes Boßle created CAMEL-19996:
--------------------------------------

             Summary: camel-lra NullPointerException when creating a saga with invalid lra-url
                 Key: CAMEL-19996
                 URL: https://issues.apache.org/jira/browse/CAMEL-19996
             Project: Camel
          Issue Type: Bug
          Components: camel-lra
    Affects Versions: 4.1.0
            Reporter: Johannes Boßle


There is a NullpointerException occurring, when
 * you start a new saga (required, automatic completion)
 * your configured lra is not valid (e.g. you get some arbitrary page from this url)

As a result, the request never ends and runs infinite.
{noformat}
org.apache.camel.service.lra.LRAClient.newLRA()
  is calling org.apache.camel.service.lra.LRAClient.toURL(Object)
    -> throw new RuntimeCamelException(ex);
--> this is kind of expected, but now the error is handled

the call was initiated by 

org.apache.camel.processor.saga.RequiredSagaProcessor.process(Exchange, AsyncCallback)

and ends up finally in 

org.apache.camel.processor.saga.SagaProcessor.ifNotException(Throwable, Exchange, boolean, CamelSagaCoordinator, CamelSagaCoordinator, AsyncCallback, Runnable) {
            if (ex != null) {
               exchange.setException(ex);
            if (handleCompletion) {
                handleSagaCompletion(exchange, coordinator, previousCoordinator, callback);
            } else {

Since org.apache.camel.processor.saga.SagaProcessor.handleSagaCompletion(Exchange, CamelSagaCoordinator, CamelSagaCoordinator, AsyncCallback) is called 
with completionMode == SagaCompletionMode.AUTO
            if (exchange.getException() != null) {
                coordinator.compensate().whenComplete(...
  coordinator is always null, because newSaga was not yet (sucessfully) executed{noformat}
Since the NPE occurs during the errorHandling of the invalid URL itself, it is retried to infinity or something else happens, which never retunrs in awaitable time.

 

Proposal Fix

A coordinator should only be null, if there is no saga present yet. So in this case it would be safe to call 
{noformat}
callback.done(false){noformat}
instead of trying to call some methods of the coordinator to rollback.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)