]> source.dussan.org Git - archiva.git/commitdiff
prevent possible file limit issue
authorOlivier Lamy <olamy@apache.org>
Mon, 16 Dec 2013 06:53:09 +0000 (06:53 +0000)
committerOlivier Lamy <olamy@apache.org>
Mon, 16 Dec 2013 06:53:09 +0000 (06:53 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1551121 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-base/archiva-filelock/src/main/java/org/apache/archiva/common/filelock/DefaultFileLockManager.java
archiva-modules/archiva-base/archiva-filelock/src/main/java/org/apache/archiva/common/filelock/Lock.java

index e97d3e141de667adfaea46672c7581272651fb47..db26076b9a945fa8c59c93f70a50a656f13647ec 100644 (file)
@@ -27,6 +27,7 @@ import org.springframework.stereotype.Service;
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.IOException;
+import java.io.RandomAccessFile;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 
@@ -91,6 +92,12 @@ public class DefaultFileLockManager
                 if ( current != null )
                 {
                     log.debug( "read lock file exist continue wait" );
+                    // close RandomAccessFile!!!
+                    RandomAccessFile raf =  lock.getRandomAccessFile();
+                    if (raf != null)
+                    {
+                        raf.close();
+                    }
                     continue;
                 }
 
@@ -168,14 +175,21 @@ public class DefaultFileLockManager
 
                 Lock current = lockFiles.get( file );
 
-                if ( current != null )
-                {
-                    log.debug( "write lock file exist continue wait" );
-                    continue;
-                }
-
                 try
                 {
+
+                    if ( current != null )
+                    {
+                        log.debug( "write lock file exist continue wait" );
+                        // close RandomAccessFile!!!
+                        RandomAccessFile raf =  lock.getRandomAccessFile();
+                        if (raf != null)
+                        {
+                            raf.close();
+                        }
+                        continue;
+                    }
+
                     createNewFileQuietly( file );
                     lock.openLock( true, timeout > 0 );
                     acquired = true;
index a05d7d2c54001dbb28a59ce8cc7cdd04d2fe50a2..0922a7495b2079cc0589e2a53a7c38963eceba3d 100644 (file)
@@ -144,6 +144,10 @@ public class Lock
 
     }
 
+    protected RandomAccessFile getRandomAccessFile()
+    {
+        return randomAccessFile;
+    }
 
     private void closeQuietly( Closeable closeable )
     {