]> source.dussan.org Git - archiva.git/commitdiff
prevent possible race condition if the file has been deleted
authorOlivier Lamy <olamy@apache.org>
Mon, 16 Dec 2013 03:35:55 +0000 (03:35 +0000)
committerOlivier Lamy <olamy@apache.org>
Mon, 16 Dec 2013 03:35:55 +0000 (03:35 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1551109 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-base/archiva-filelock/src/main/java/org/apache/archiva/common/filelock/DefaultFileLockManager.java

index 7d1011998074f2fcab7b7cf7da49659fe7d96751..e97d3e141de667adfaea46672c7581272651fb47 100644 (file)
@@ -65,7 +65,7 @@ public class DefaultFileLockManager
         try
         {
 
-            Lock lock = new Lock( file, false );
+            Lock lock = null;
 
             stopWatch.start();
 
@@ -84,6 +84,8 @@ public class DefaultFileLockManager
                     }
                 }
 
+                lock = new Lock( file, false );
+
                 Lock current = lockFiles.get( file );
 
                 if ( current != null )
@@ -143,12 +145,13 @@ public class DefaultFileLockManager
 
         try
         {
-            Lock lock = new Lock( file, true );
+            Lock lock = null;
 
             stopWatch.start();
 
             while ( !acquired )
             {
+
                 if ( timeout > 0 )
                 {
                     long delta = stopWatch.getTime();
@@ -161,6 +164,8 @@ public class DefaultFileLockManager
                     }
                 }
 
+                lock = new Lock( file, true );
+
                 Lock current = lockFiles.get( file );
 
                 if ( current != null )