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

Rahul Akolkar commented on SCXML-67:
------------------------------------

Thanks for the test case and the proposed fix. Looks good, except that the else 
clause might need to be an else if. I am traveling till end of this month, and 
largely offline, but I will try to find time to get the fix in soon.


> <state> can't have <parallel> 
> ------------------------------
>
>                 Key: SCXML-67
>                 URL: https://issues.apache.org/jira/browse/SCXML-67
>             Project: Commons SCXML
>          Issue Type: Bug
>    Affects Versions: 0.7
>            Reporter: SeongSoo, Park
>             Fix For: 0.8
>
>
> According to the latest SCXML W/D the <state> can have <parallel> as its 
> child.
> But, Commons SCXML 0.7 doesn't  seems to support that. 
> The  org.apache.commons.scxml.io.SCXMLParser can't parse this scxml doc. 
> <?xml version="1.0"?>
> <scxml xmlns="http://www.w3.org/2005/07/scxml"; version="1.0"
>   initialstate="microwave"> 
>   <state id="microwave">
>    <initial>
>           <transition  target="parts"/>        
>     </initial>
>     <parallel id="parts">
>       <state id="oven">
>           <initial>
>                <transition  target="oven2"/>   
>           </initial>
>              <state id= "oven2">
>                <transition event="exit"  target="dest"/>
>              </state>
>       </state>
>       <state id="door">
>              <initial>
>                    <transition  target="door2"/>       
>              </initial>
>               <state id= "door2">
>        <transition event="e" target="dest"/>
>              </state>
>       </state>
>     </parallel>
>   </state>
>   <state id= "dest"  final ="true"/>
> </scxml>
> The SCXML  engine generates the following exception during parsing the scxml 
> doc.
> Exception in thread "main" java.lang.ClassCastException: 
> org.apache.commons.scxml.model.Parallel
>       at 
> org.apache.commons.scxml.io.ModelUpdater.updateState(ModelUpdater.java:213)
>       at 
> org.apache.commons.scxml.io.ModelUpdater.updateSCXML(ModelUpdater.java:78)
>       at org.apache.commons.scxml.io.SCXMLParser.parse(SCXMLParser.java:268)
>       at org.apache.commons.scxml.io.SCXMLParser.parse(SCXMLParser.java:152)
>       at 
> org.apache.commons.scxml.test.StandaloneUtils.execute(StandaloneUtils.java:80)
>       at 
> org.apache.commons.scxml.test.StandaloneJexlExpressions.main(StandaloneJexlExpressions.java:60)
> So, I fixed  the 'updateState()' in org.apache.commons.scxml.io.ModelUpdater 
> class like this 
> (and also org.apache.commons.scxml.io.SCXMLSerializer.serializeState() )
>         ..........
>         } else {
>             Iterator j = c.keySet().iterator();
>             /* ---- your code  ----
>             while (j.hasNext()) {
>                 updateState((State) c.get(j.next()), targets);
>             }
>              */
>             /* -------   my fixed code ---------*/
>             while (j.hasNext()) {
>                TransitionTarget tt = (TransitionTarget) c.get(j.next());
>                 if (tt instanceof State) {
>                    updateState((State) tt, targets);
>                 } else {
>                    updateParallel((Parallel) tt, targets);
>                }
>            }
>           /*  ------------------------------------*/
>         }
>     } /* end of  'updateState()' */
> So, the engine works well. 
> I think this is a critical bug. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to