You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by fe...@apache.org on 2011/10/08 19:08:42 UTC

svn commit: r1180416 - /james/server/trunk/queue-activemq/src/main/java/org/apache/james/queue/activemq/FileSystemBlobStrategy.java

Author: felixk
Date: Sat Oct  8 17:08:42 2011
New Revision: 1180416

URL: http://svn.apache.org/viewvc?rev=1180416&view=rev
Log:
Use synchronized block on the file in charge to make thread safe. See JAMES-1327

Modified:
    james/server/trunk/queue-activemq/src/main/java/org/apache/james/queue/activemq/FileSystemBlobStrategy.java

Modified: james/server/trunk/queue-activemq/src/main/java/org/apache/james/queue/activemq/FileSystemBlobStrategy.java
URL: http://svn.apache.org/viewvc/james/server/trunk/queue-activemq/src/main/java/org/apache/james/queue/activemq/FileSystemBlobStrategy.java?rev=1180416&r1=1180415&r2=1180416&view=diff
==============================================================================
--- james/server/trunk/queue-activemq/src/main/java/org/apache/james/queue/activemq/FileSystemBlobStrategy.java (original)
+++ james/server/trunk/queue-activemq/src/main/java/org/apache/james/queue/activemq/FileSystemBlobStrategy.java Sat Oct  8 17:08:42 2011
@@ -104,8 +104,8 @@ public class FileSystemBlobStrategy impl
      */
     public void deleteFile(ActiveMQBlobMessage message) throws IOException, JMSException {
         File f = getFile(message);
-        if (f.exists()) {
-            if (f.delete() == false) {
+        synchronized (f) {
+            if (f.exists() && !f.delete()) {
                 throw new IOException("Unable to delete file " + f);
             }
         }
@@ -143,20 +143,12 @@ public class FileSystemBlobStrategy impl
 
         File queueF = fs.getFile(queueUrl);
 
-        // check if we need to create the queue folder
-        if (!queueF.exists()) {
-            if (!queueF.mkdirs()) {
-                // It could be that queueF.mkdirs() returned false because
-                // queueF has been created
-                // in the meantime (eg. by a different thread). Only throw an
-                // exception if this is
-                // not the case.
-                if (!queueF.exists()) {
-                    throw new IOException("Unable to create directory " + queueF.getAbsolutePath());
-                }
+        synchronized (queueF) {
+            // check if we need to create the queue folder
+            if (!queueF.exists() && !queueF.mkdirs()) {
+                throw new IOException("Unable to create directory " + queueF.getAbsolutePath());
             }
-         
-         }
+        }
 
         return fs.getFile(queueUrl + "/" + filename);
 



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