aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-modules/archiva-base/archiva-filelock/src
diff options
context:
space:
mode:
authorMartin Stockhammer <martin_s@apache.org>2016-10-27 12:21:46 +0200
committerMartin Stockhammer <martin_s@apache.org>2016-10-27 12:22:56 +0200
commitd380bc6779aeefb80b74923d5ffa2e0c50994709 (patch)
tree698946f029df4191c14350a343b3087e1e9fd9da /archiva-modules/archiva-base/archiva-filelock/src
parent8dc5e696d225ae3607b861063ca191e993c60898 (diff)
downloadarchiva-d380bc6779aeefb80b74923d5ffa2e0c50994709.tar.gz
archiva-d380bc6779aeefb80b74923d5ffa2e0c50994709.zip
Additional improvement for file locks
Diffstat (limited to 'archiva-modules/archiva-base/archiva-filelock/src')
-rw-r--r--archiva-modules/archiva-base/archiva-filelock/src/main/java/org/apache/archiva/common/filelock/DefaultFileLockManager.java18
-rw-r--r--archiva-modules/archiva-base/archiva-filelock/src/test/java/org/apache/archiva/common/filelock/DefaultFileLockManagerTest.java4
2 files changed, 16 insertions, 6 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 2ce2f188c..258366aa9 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
@@ -198,28 +198,38 @@ public class DefaultFileLockManager
}
throw new FileLockException( e.getMessage(), e );
}
- catch ( Throwable e )
+ catch ( IllegalStateException e )
{
+ // Ignore this
+ log.debug( "openLock {}:{}", e.getClass(), e.getMessage() );
+ } catch (Throwable t) {
if (lock!=null && lock.isValid()) {
try {
lock.close();
} catch (IOException ex) {
// Ignore
- } finally {
- lock = null;
}
}
- log.debug( "openLock {}:{}", e.getClass(), e.getMessage() );
+ throw t;
}
}
Lock current = lockFiles.putIfAbsent( file, lock );
+ if (lock!=null && lock != current) {
+ try {
+ lock.close();
+ } catch (IOException e) {
+ // ignore
+ }
+
+ }
if ( current != null )
{
lock = current;
}
+
return lock;
diff --git a/archiva-modules/archiva-base/archiva-filelock/src/test/java/org/apache/archiva/common/filelock/DefaultFileLockManagerTest.java b/archiva-modules/archiva-base/archiva-filelock/src/test/java/org/apache/archiva/common/filelock/DefaultFileLockManagerTest.java
index 96186612e..19f836dbc 100644
--- a/archiva-modules/archiva-base/archiva-filelock/src/test/java/org/apache/archiva/common/filelock/DefaultFileLockManagerTest.java
+++ b/archiva-modules/archiva-base/archiva-filelock/src/test/java/org/apache/archiva/common/filelock/DefaultFileLockManagerTest.java
@@ -246,7 +246,7 @@ public class DefaultFileLockManagerTest
public void thread9()
throws FileLockException, FileLockTimeoutException, IOException
{
- logger.info( "thread7" );
+ logger.info( "thread9" );
Lock lock = fileLockManager.writeFileLock( this.file );
try
{
@@ -274,7 +274,7 @@ public class DefaultFileLockManagerTest
{
fileLockManager.release( lock );
}
- logger.info( "thread8 ok" );
+ logger.info( "thread10 ok" );
success.incrementAndGet();
}