Johannes Wienke created SCXML-207:
-------------------------------------

             Summary: Race condition in transition notification for 
SCXMLListeners
                 Key: SCXML-207
                 URL: https://issues.apache.org/jira/browse/SCXML-207
             Project: Commons SCXML
          Issue Type: Bug
    Affects Versions: 2.0
            Reporter: Johannes Wienke


When using a SimpleSCXMLListener we have seen impossible transitions occur in 
the log output of that listener. After digging around the source code I can see 
the issue that results in theses outputs.

In order to derive the event name passed as the last argument to 
SCXMLListener#onTransition, the following code inside SCXMLSemanticsImpl is 
used:
{code:java}
public void notifyOnTransition(final SCXMLExecutionContext exctx, final 
Transition t,
                                      final TransitionTarget target) {
    EventVariable event = 
(EventVariable)exctx.getScInstance().getSystemContext().getVars().get(SCXMLSystemContext.EVENT_KEY);
    String eventName = event != null ? event.getName() : null;
    exctx.getNotificationRegistry().fireOnTransition(t, t.getParent(), target, 
t, eventName);
    exctx.getNotificationRegistry().fireOnTransition(exctx.getStateMachine(), 
t.getParent(), target, t, eventName);
    }
{code}
When triggering events on the engine from multiple threads (which is ok 
according to the online documentation), a different thread might have already 
replaced the contents of the SCXMLSystemContext.EVENT_KEY context item and 
hence a wrong event name might be used from this point on.

Actually, I don't even understand why the event name is looked up from the 
context here at all, since is already available inside the transition.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to