aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-modules/archiva-base/archiva-filelock
diff options
context:
space:
mode:
authorOlivier Lamy <olamy@apache.org>2013-12-16 03:35:55 +0000
committerOlivier Lamy <olamy@apache.org>2013-12-16 03:35:55 +0000
commit4e077a844eccebac9cce6c37d040eae7be9ed39c (patch)
tree8631270022d1e5df68aa51e7cb62b47d730a12ee /archiva-modules/archiva-base/archiva-filelock
parent6fee2f195fa1d7749803e5e8e6531466cdb0ab72 (diff)
downloadarchiva-4e077a844eccebac9cce6c37d040eae7be9ed39c.tar.gz
archiva-4e077a844eccebac9cce6c37d040eae7be9ed39c.zip
prevent possible race condition if the file has been deleted
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1551109 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules/archiva-base/archiva-filelock')
-rw-r--r--archiva-modules/archiva-base/archiva-filelock/src/main/java/org/apache/archiva/common/filelock/DefaultFileLockManager.java9
1 files changed, 7 insertions, 2 deletions
diff --git a/archiva-modules/archiva-base/archiva-filelock/src/main/java/org/apache/archiva/common/filelock/DefaultFileLockManager.java b/archiva-modules/archiva-base/archiva-filelock/src/main/java/org/apache/archiva/common/filelock/DefaultFileLockManager.java
index 7d1011998..e97d3e141 100644
--- a/archiva-modules/archiva-base/archiva-filelock/src/main/java/org/apache/archiva/common/filelock/DefaultFileLockManager.java
+++ b/archiva-modules/archiva-base/archiva-filelock/src/main/java/org/apache/archiva/common/filelock/DefaultFileLockManager.java
@@ -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 )