commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andy Bailey (JIRA)" <j...@apache.org>
Subject [jira] Commented: (SCXML-60) Possible race condition in AsyncTrigger
Date Sat, 03 Nov 2007 05:43:09 GMT

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

Andy Bailey commented on SCXML-60:
----------------------------------

I didnt actually observe the problem, I think you need a multiprocessor
machine for that to happen, but I thought it would be a good idea to fix
it as if it ever did happen it would be difficult to debug, and almost
impossible to reproduce.




> Possible race condition in AsyncTrigger
> ---------------------------------------
>
>                 Key: SCXML-60
>                 URL: https://issues.apache.org/jira/browse/SCXML-60
>             Project: Commons SCXML
>          Issue Type: Bug
>    Affects Versions: 0.6
>            Reporter: Andy Bailey
>            Priority: Minor
>             Fix For: 0.7
>
>
> In AsyncTrigger (used by SimpleSCXMLInvoker) a thread is started from inside the constuctor,
because of the java memory model the fields arent guaranteed to be written until after the
constructor ends, however the thread could start before this and so the values could be null.
> To be safe the class should have a start method that gets invoked after the constructor.
>   AsyncTrigger(final SCXMLExecutor executor, final TriggerEvent event) {
>         this.executor = executor;
>         this.events = new TriggerEvent[1];
>         this.events[0] = event;
>         new Thread(this).start();
>     }
>  public void run() {
>         try {
>             synchronized (executor) {
>                 executor.triggerEvents(events);
>             }
>         } catch (ModelException me) {
>             log.error(me.getMessage(), me);
>         }
>     }

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


Mime
View raw message