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] Created: (SCXML-60) Possible race condition in AsyncTrigger
Date Fri, 19 Oct 2007 18:19:50 GMT
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.


Mime
View raw message