You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Andy Bailey (JIRA)" <ji...@apache.org> on 2007/10/19 20:19:50 UTC

[jira] Created: (SCXML-60) Possible race condition in AsyncTrigger

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


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.


[jira] Resolved: (SCXML-60) Possible race condition in AsyncTrigger

Posted by "Rahul Akolkar (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SCXML-60?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Rahul Akolkar resolved SCXML-60.
--------------------------------

    Resolution: Fixed

Fixed in SVN, thanks for your input, I've added your name to the project contributors section.


> 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.


[jira] Commented: (SCXML-60) Possible race condition in AsyncTrigger

Posted by "Andy Bailey (JIRA)" <ji...@apache.org>.
    [ 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.


[jira] Updated: (SCXML-60) Possible race condition in AsyncTrigger

Posted by "Rahul Akolkar (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SCXML-60?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Rahul Akolkar updated SCXML-60:
-------------------------------

    Fix Version/s: 0.7

Setting fix version to v0.7 so it gets fixed in the next release.

Out of curiosity, did you actually observe this problem, what JDK etc.?


> 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.