You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@archiva.apache.org by ma...@apache.org on 2017/06/10 11:25:57 UTC

[12/50] archiva git commit: Reverting locking modifications

Reverting locking modifications


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

Branch: refs/heads/citest
Commit: 4c35ccef7b3cbad1536077febbb8395abac4d70c
Parents: 40816fc
Author: Martin Stockhammer <ma...@apache.org>
Authored: Thu Oct 27 17:36:27 2016 +0200
Committer: Martin Stockhammer <ma...@apache.org>
Committed: Thu Oct 27 17:36:27 2016 +0200

----------------------------------------------------------------------
 .../common/filelock/DefaultFileLockManager.java | 39 ++++----------------
 1 file changed, 7 insertions(+), 32 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/archiva/blob/4c35ccef/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 258366a..ee4fb35 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
@@ -31,7 +31,6 @@ import java.io.RandomAccessFile;
 import java.nio.channels.ClosedChannelException;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
 
 /**
  * @author Olivier Lamy
@@ -52,6 +51,7 @@ public class DefaultFileLockManager
 
     private int timeout = 0;
 
+
     @Override
     public Lock readFileLock( File file )
         throws FileLockException, FileLockTimeoutException
@@ -162,18 +162,20 @@ public class DefaultFileLockManager
                 }
             }
 
+            Lock current = lockFiles.get( file );
+
             try
             {
-                Lock current = lockFiles.get( file );
+
                 if ( current != null )
                 {
                     log.debug( "write lock file exist continue wait" );
 
                     continue;
                 }
-                lock = new Lock(file, true);
-                createNewFileQuietly(file);
-                lock.openLock(true, timeout > 0);
+                lock = new Lock( file, true );
+                createNewFileQuietly( file );
+                lock.openLock( true, timeout > 0 );
                 acquired = true;
             }
             catch ( FileNotFoundException e )
@@ -189,47 +191,20 @@ public class DefaultFileLockManager
             }
             catch ( IOException e )
             {
-                if (lock!=null && lock.isValid()) {
-                    try {
-                        lock.close();
-                    } catch (IOException ex) {
-                        // Ignore
-                    }
-                }
                 throw new FileLockException( e.getMessage(), 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
-                    }
-                }
-                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;