Uploaded image for project: 'James Server'
  1. James Server
  2. JAMES-1327

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

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 3.0-beta3
    • 3.0-beta4
    • Queue
    • None
    • At least Windows and Linux.

    Description

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

      Attachments

        1. JAMES-1327.patch
          1 kB
          Michael Herrmann

        Issue Links

          Activity

            People

              norman Norman Maurer
              mherrmann Michael Herrmann
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: