Uploaded image for project: 'camunda BPM'
  1. camunda BPM
  2. CAM-14740

Sending signal can cause unexpected NPE in race condition




      Environment (Required on creation):

      Tested with 7.17 spring boot, likely happens with other versions, too.

      Description (Required on creation; please attach any relevant screenshots, stacktraces, log files, etc. to the ticket):

      If we send a signal to an execution that exists at the time of sending but finishes just after we've sent the signal then the send method will throw a NullPointerException. This can cause failures in client applications as they don't expect a NPE here.

      Steps to reproduce (Required on creation):

      As this only happens in a race condition, the easiest to reproduce this is in an IDE with breakpoints.
      Start two processes simultaneously, have a user task in both so they don't finish immediately. One of the process needs to have a step after the user task where it sends a signal to the other one. Right after the signal send was called, the other execution should finish --> To achieve this, the simplest is to set a breakpoint in the SignalEventReceivedCmd.sendSignalToExecution() method at the line of checkAuthorizationOfCatchSignals then we finish the other process' user task and finally we let go the suspended other process.
      The send method will throw a NPE.

      There is a complete example in the support ticket.

      Observed Behavior (Required on creation):

      The send throws a NPE.

      Expected behavior (Required on creation):

      It shouldn't throw a NPE.

      Root Cause (Required on prioritization):

      Problem seems to be that both `ExecutionEntity.ensureExecutionsInitialized` and `ExecutionEntity.ensureExecutionTreeInitialized` aren't initializing the executions, leaving it null. Which kind of make sense, since the execution had already finished but still the method names suggest that they should in fact ensure it is initialized.

      This is the exception being thrown:

      java.lang.NullPointerException: Cannot invoke "java.util.List.iterator()" because "children" is null
          at org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl.getNonEventScopeExecutions(PvmExecutionImpl.java:1098)
          at org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl.createConcurrentExecution(PvmExecutionImpl.java:527)

      Solution Ideas (Optional):

      How should the method send end in this case:

      Hints (optional):


        This is the controller panel for Smart Panels app


          Issue Links



                michael.schoettes Michael Schoettes
                daniel.kelemen Daniel Kelemen
                Daniel Kelemen Daniel Kelemen
                Thorben Lindhauer Thorben Lindhauer
                0 Vote for this issue
                4 Start watching this issue