[ 
https://issues.apache.org/jira/browse/SCXML-105?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13194592#comment-13194592
 ] 

Toby Shepheard commented on SCXML-105:
--------------------------------------

This issue has caught me out; I worked around it in a similar manner to Mike's 
proposal above, by splitting the actions between pre- and post- transition and 
updating the status in between. 

This appears to match what the SCXML standard dictates in their psuedo-code as 
listed under http://www.w3.org/TR/scxml/#AlgorithmforSCXMLInterpretation. In 
procedure enterStates(enabledTransitions), the new state is put into the 
configuration before the call to any onEntry actions:

{code}
 for s in statesToEnter:
        configuration.add(s)  // <----  State is updated here
        if binding == "late" and s.isFirstEntry:
            initializeDataModel(datamodel.s,doc.s)
            s.isFirstEntry = false
        for content in s.onentry:
            executeContent(content)   //  <-------- onentry actions are 
executed here
{code}
The earlier onExit and transition actions are handled as part of the microstep, 
from which I'd infer that the transition technically takes place whilst still 
in the previous state.

{code}
procedure microstep(enabledTransitions):
    exitStates(enabledTransitions)
    executeTransitionContent(enabledTransitions)
    enterStates(enabledTransitions)
{code}

Even if the change is not 100% perfect (I note the comments about rollback) I 
feel it would be more correct this way and cause fewer people problems.
                
> Current status updated after onentry is called
> ----------------------------------------------
>
>                 Key: SCXML-105
>                 URL: https://issues.apache.org/jira/browse/SCXML-105
>             Project: Commons SCXML
>          Issue Type: Bug
>    Affects Versions: 0.9
>            Reporter: Mike Tillberg
>            Priority: Minor
>             Fix For: 0.10
>
>         Attachments: CustomActionTest.patch, GetStateAction.java, 
> custom-state-01.xml
>
>
> When retrieving the current state using a custom action in the onentry 
> section of a state, the state is incorrect.  The state retrieved is the 
> previous state.  The problem appears to be in SCXMLExecutor.triggerEvents, 
> where updateStatus() is called after semantics.executeActions().  Adding an 
> additional updateStatus() before executeActions() seems to fix the problem, 
> and all tests still pass.
> Attached is a test case showing the problem.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to