[ 
https://issues.apache.org/jira/browse/SCXML-167?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Woonsan Ko resolved SCXML-167.
------------------------------

    Resolution: Fixed

Fixed.

Thank you very much for reporting this and giving a solution, Maikel Linke!

Cheers,

Woonsan

> SimpleScheduler removes wrong Timer
> -----------------------------------
>
>                 Key: SCXML-167
>                 URL: https://issues.apache.org/jira/browse/SCXML-167
>             Project: Commons SCXML
>          Issue Type: Bug
>    Affects Versions: 0.5, 0.6, 0.7, 0.8, 0.9
>         Environment: supersteps activated
>            Reporter: Maikel Linke
>            Assignee: Woonsan Ko
>              Labels: cancel, delay, patch, send, timing
>             Fix For: 2.0
>
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> The SimpleScheduler provides the execution of delayed events. Therefore it 
> uses Timers, stored in a map under the senderid. The Timers start 
> DelayedEventTasks. These tasks trigger the given event and then remove their 
> Timer identified by the senderid. In the case that triggering the event 
> processes a new <send> with the same senderid, the task will remove the wrong 
> (new) Timer from the internal map. This new Timer is unreachable for 
> canceling now. Of course, the senderid should be unique, but cannot be 
> assigned by an expression and the following example fails:
>     <state id="Timer">
>         <onentry>
>             <send event="'tick'" sendid="sendtick" delay="'1s'"/>
>         </onentry>
>         <transition event="tick" target="Timer"/>
>         <transition event="stop" target="NoTimer"/>
>         <onexit>
>             <cancel sendid="sendtick"/>
>         </onexit>
>     </state>
> The solution is very simple: just remove the Timer from the Map first and 
> then trigger the event.
> So this code:
>         public void run() {
>             try {
>                 executor.triggerEvent(new TriggerEvent(event,
>                     TriggerEvent.SIGNAL_EVENT, payload));
>             } catch (ModelException me) {
>                 log.error(me.getMessage(), me);
>             }
>             timers.remove(sendId);
>             if (log.isDebugEnabled()) {
>                 log.debug("Fired event '" + event + "' as scheduled by "
>                     + "<send> with id '" + sendId + "'");
>             }
>         }
> Changes to:
>         public void run() {
>             timers.remove(sendId);
>             try {
>                 executor.triggerEvent(new TriggerEvent(event,
>                     TriggerEvent.SIGNAL_EVENT, payload));
>             } catch (ModelException me) {
>                 log.error(me.getMessage(), me);
>             }
>             if (log.isDebugEnabled()) {
>                 log.debug("Fired event '" + event + "' as scheduled by "
>                     + "<send> with id '" + sendId + "'");
>             }
>         }
> It should not brake any logic applied to the internal private Map timers.



--
This message was sent by Atlassian JIRA
(v6.1#6144)

Reply via email to