FileSystemBlobStrategy#getFile(ActiveMQBlobMessage) is not thread safe (throws 
"java.io.IOException: Unable to create directory")
---------------------------------------------------------------------------------------------------------------------------------

                 Key: JAMES-1327
                 URL: https://issues.apache.org/jira/browse/JAMES-1327
             Project: JAMES Server
          Issue Type: Bug
          Components: Queue
    Affects Versions: 3.0-beta3
         Environment: At least Windows and Linux. 
            Reporter: Michael Herrmann


Consider 
org.apache.james.queue.activemq.FileSystemBlobStrategy#getFile(ActiveMQBlobMessage):

    protected File getFile(ActiveMQBlobMessage message) throws JMSException, 
IOException {
        ...
        // check if we need to create the queue folder
        if (queueF.exists() == false) {
            if (!queueF.mkdirs()) {
                throw new IOException("Unable to create directory " + 
queueF.getAbsolutePath());
            }
        }
        ...
    }

Suppose this method is called from two threads. If both threads get past the 
condition
        if (queueF.exists() == false),
then the first one will create queueF. For the second, queueF.mkdirs() will 
then return false, which leads to an IOException even though everything is 
fine. I think the condition should be replaced by
        if (!queueF.mkdirs() && !queueF.exists()).

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org
For additional commands, e-mail: server-dev-h...@james.apache.org

Reply via email to