Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
0.7
-
None
Description
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())
*/
/* ------- my fixed code ---------*/
while (j.hasNext()) {
TransitionTarget tt = (TransitionTarget) c.get(j.next());
if (tt instanceof State)
else
{ updateParallel((Parallel) tt, targets); } }
/* ------------------------------------*/
}
} /* end of 'updateState()' */
So, the engine works well.
I think this is a critical bug.