You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by my...@apache.org on 2009/08/19 23:14:58 UTC

svn commit: r805978 - /db/derby/code/branches/10.1/java/engine/org/apache/derby/impl/io/DirFile4.java

Author: myrnavl
Date: Wed Aug 19 21:14:57 2009
New Revision: 805978

URL: http://svn.apache.org/viewvc?rev=805978&view=rev
Log:
DERBY-700: Port 805448 from trunk to the 10.1 branch
  only ported the code change; the new test is not appropriate

Modified:
    db/derby/code/branches/10.1/java/engine/org/apache/derby/impl/io/DirFile4.java

Modified: db/derby/code/branches/10.1/java/engine/org/apache/derby/impl/io/DirFile4.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.1/java/engine/org/apache/derby/impl/io/DirFile4.java?rev=805978&r1=805977&r2=805978&view=diff
==============================================================================
--- db/derby/code/branches/10.1/java/engine/org/apache/derby/impl/io/DirFile4.java (original)
+++ db/derby/code/branches/10.1/java/engine/org/apache/derby/impl/io/DirFile4.java Wed Aug 19 21:14:57 2009
@@ -32,6 +32,7 @@
 import java.io.RandomAccessFile;
 import java.nio.channels.FileChannel;
 import java.nio.channels.FileLock;
+import java.nio.channels.OverlappingFileLockException;
 
 /**
  * This class implements the StorageFile interface using features of Java 1.4 not available in earlier
@@ -185,7 +186,31 @@
 				SanityManager.THROWASSERT("Unable to Acquire Exclusive Lock on "
 										  + getPath());
 			}
-		}
+		} catch (OverlappingFileLockException ofle)
+        {
+            //
+            // Under Java 6 and later, this exception is raised if the database
+            // has been opened by another Derby instance in a different
+            // ClassLoader in this VM. See DERBY-700.
+            //
+            // The OverlappingFileLockException is raised by the
+            // lockFileChannel.tryLock() call above.
+            //
+            try {
+                lockFileChannel.close();
+                lockFileOpen.close();
+            } catch (IOException e)
+            {
+                if (SanityManager.DEBUG)
+                {
+                    SanityManager.THROWASSERT("Error closing file channel "
+                                              + getPath(), e);
+                }
+            }
+            lockFileChannel=null;
+            lockFileOpen = null;
+            status = EXCLUSIVE_FILE_LOCK_NOT_AVAILABLE;
+        }
     
 		return status;
 	} // end of getExclusiveFileLock