Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-19996

camel-lra NullPointerException when creating a saga with invalid lra-url

    XMLWordPrintableJSON

Details

    • Unknown

    Description

      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.

      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

      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 

      callback.done(false)

      instead of trying to call some methods of the coordinator to rollback.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              johbossle Johannes Boßle
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: