From 4e077a844eccebac9cce6c37d040eae7be9ed39c Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Mon, 16 Dec 2013 03:35:55 +0000 Subject: [PATCH] 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 --- .../archiva/common/filelock/DefaultFileLockManager.java | 9 +++++++-- 1 file 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 ) -- 2.39.5