From: Olivier Lamy Date: Mon, 16 Dec 2013 03:35:55 +0000 (+0000) Subject: prevent possible race condition if the file has been deleted X-Git-Tag: archiva-2.0.0-RC1~106 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=4e077a844eccebac9cce6c37d040eae7be9ed39c;p=archiva.git 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 --- 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 )