db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r1509687 - in /db/derby/code/branches/10.9: ./ java/engine/org/apache/derby/impl/jdbc/LOBStreamControl.java
Date Fri, 02 Aug 2013 13:19:10 GMT
Author: kmarsden
Date: Fri Aug  2 13:19:10 2013
New Revision: 1509687

URL: http://svn.apache.org/r1509687
Log:
DERBY-6092 testPositionAgressive(org.apache.derbyTesting.functionTests.tests.jdbcapi.BlobClob4BlobTest)j
fails with : 'The handle is invalid.: java.io.IOException'

Merged from 10.10 revision 1466378
Contributed by Knut Anders Hatlen


Modified:
    db/derby/code/branches/10.9/   (props changed)
    db/derby/code/branches/10.9/java/engine/org/apache/derby/impl/jdbc/LOBStreamControl.java

Propchange: db/derby/code/branches/10.9/
------------------------------------------------------------------------------
  Merged /db/derby/code/trunk:r1466362
  Merged /db/derby/code/branches/10.10:r1466378

Modified: db/derby/code/branches/10.9/java/engine/org/apache/derby/impl/jdbc/LOBStreamControl.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.9/java/engine/org/apache/derby/impl/jdbc/LOBStreamControl.java?rev=1509687&r1=1509686&r2=1509687&view=diff
==============================================================================
--- db/derby/code/branches/10.9/java/engine/org/apache/derby/impl/jdbc/LOBStreamControl.java
(original)
+++ db/derby/code/branches/10.9/java/engine/org/apache/derby/impl/jdbc/LOBStreamControl.java
Fri Aug  2 13:19:10 2013
@@ -530,8 +530,22 @@ class LOBStreamControl {
      * @throws IOException if the file cannot be closed or deleted
      */
     private void releaseTempFile(LOBFile file) throws IOException {
-        file.close();
+        // Remove the file from the list of open files *first*, then close it.
+        //
+        // Why? This code may be called from finalize(), and may end up running
+        // at the same time the transaction is committed or rolled back. If two
+        // threads call RandomAccessFile.close() at the same time, Java 5 could
+        // fail (see DERBY-6092). By removing it from the list before closing
+        // it, we make sure that EmbedConnection.clearLOBMapping() won't see
+        // it if we get to the file first. Conversely, if clearLOBMapping()
+        // gets to it first, the call to removeLobFile() will block until
+        // clearLOBMapping() is done, so we won't attempt to close the file
+        // until after clearLOBMapping() is done, rather than at the same time.
+        //
+        // Calling close() concurrently is safe on Java 6 and newer, after the
+        // fix for http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6322678 .
         conn.removeLobFile(file);
+        file.close();
         deleteFile(file.getStorageFile());
     }
     



Mime
View raw message