archiva-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From marti...@apache.org
Subject [13/20] archiva git commit: Additional improvement for file locks
Date Sun, 21 May 2017 21:48:12 GMT
Additional improvement for file locks


Project: http://git-wip-us.apache.org/repos/asf/archiva/repo
Commit: http://git-wip-us.apache.org/repos/asf/archiva/commit/40816fc3
Tree: http://git-wip-us.apache.org/repos/asf/archiva/tree/40816fc3
Diff: http://git-wip-us.apache.org/repos/asf/archiva/diff/40816fc3

Branch: refs/heads/master
Commit: 40816fc367fce33c4220fbd683dbd8db75fbb781
Parents: f327eb9
Author: Martin Stockhammer <martin_s@apache.org>
Authored: Thu Oct 27 12:21:46 2016 +0200
Committer: Martin Stockhammer <martin_s@apache.org>
Committed: Thu Oct 27 12:21:46 2016 +0200

----------------------------------------------------------------------
 .../common/filelock/DefaultFileLockManager.java   | 18 ++++++++++++++----
 .../filelock/DefaultFileLockManagerTest.java      |  4 ++--
 2 files changed, 16 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/archiva/blob/40816fc3/archiva-modules/archiva-base/archiva-filelock/src/main/java/org/apache/archiva/common/filelock/DefaultFileLockManager.java
----------------------------------------------------------------------
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 2ce2f18..258366a 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;
 
 

http://git-wip-us.apache.org/repos/asf/archiva/blob/40816fc3/archiva-modules/archiva-base/archiva-filelock/src/test/java/org/apache/archiva/common/filelock/DefaultFileLockManagerTest.java
----------------------------------------------------------------------
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 9618661..19f836d 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();
         }
 


Mime
View raw message