Commons SCXML
  1. Commons SCXML
  2. SCXML-61

Infinite loop if an Invoker fires the done event in invoke method

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 0.6
    • Fix Version/s: 0.7
    • Labels:
      None
    • Environment:

      all platforms

      Description

      With the following code

      public class HazInvoker implements Invoker
      {
      @Override public void invoke(String source, Map parameters) throws InvokerException
      {
      System.out.println("Invoker invoke source: "source" params: "+parameters);
      SCXMLExecutor executor = scInstance.getExecutor();
      TriggerEvent event=new TriggerEvent(parentStateId+".invoker.done", TriggerEvent.SIGNAL_EVENT);

      //new AsyncTrigger(executor, event);
      try

      { executor.triggerEvent(event); }

      catch (ModelException ex)

      { ex.printStackTrace(); }

      }

      Exception in thread "main" java.lang.StackOverflowError
      at java.util.Vector.addElement(Vector.java:573)
      at java.util.Stack.push(Stack.java:50)
      ...
      at org.apache.commons.scxml.semantics.SCXMLSemanticsImpl.initiateInvokes(SCXMLSemanticsImpl.java:824)
      at org.apache.commons.scxml.SCXMLExecutor.triggerEvents(SCXMLExecutor.java:142)
      at org.apache.commons.scxml.SCXMLExecutor.triggerEvent(SCXMLExecutor.java:160)
      at com.hazlorealidad.fsm.HazInvoker.invoke(HazInvoker.java:37)
      at org.apache.commons.scxml.semantics.SCXMLSemanticsImpl.initiateInvokes(SCXMLSemanticsImpl.java:824)
      at org.apache.commons.scxml.SCXMLExecutor.triggerEvents(SCXMLExecutor.java:142)
      at org.apache.commons.scxml.SCXMLExecutor.triggerEvent(SCXMLExecutor.java:160)
      at com.hazlorealidad.fsm.HazInvoker.invoke(HazInvoker.java:37)

      The fix is to use the AsyncTrigger but the class is package private, I would be good to change it to public and document the way to write a synchronous invoker in the invoke method.

      Something like:
      "If the Invoker completes its invocation in the invoke method it should signal the completion of the task using an AsyncTrigger, in order to avoid a stack overflow"

      Or maybe there is another solution which would allow the event to be fired in the invoke method.

      Also it would be good to avoid the creation of a thread just for that, maybe an invokeLater method in the executor, like the swing dispatch loop.

        Activity

        Rahul Akolkar made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Rahul Akolkar made changes -
        Resolution Fixed [ 1 ]
        Status Open [ 1 ] Resolved [ 5 ]
        Rahul Akolkar made changes -
        Field Original Value New Value
        Fix Version/s 0.7 [ 12312252 ]
        Andy Bailey created issue -

          People

          • Assignee:
            Unassigned
            Reporter:
            Andy Bailey
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development