[
https://issues.apache.org/jira/browse/SCXML-167?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13824009#comment-13824009
]
Woonsan Ko commented on SCXML-167:
----------------------------------
Your suggestion makes sense to me.
Even if the sendid should be unique, it wouldn't hurt by removing the timer
first from the map and triggering the event next because it should remove the
timer in the end anyway. It's actually safer to do this even for some corner
cases.
I will fix this soon by following your suggestion.
Thanks a lot!
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
> 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)