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 km...@apache.org on 2015/10/19 17:41:04 UTC

svn commit: r1709431 - in /db/derby/code/trunk/java: engine/org/apache/derby/impl/jdbc/LOBStoredProcedure.java testing/org/apache/derbyTesting/functionTests/tests/jdbc4/BlobTest.java testing/org/apache/derbyTesting/functionTests/tests/jdbc4/ClobTest.java

Author: kmarsden
Date: Mon Oct 19 15:41:04 2015
New Revision: 1709431

URL: http://svn.apache.org/viewvc?rev=1709431&view=rev
Log:
DERBY-5605 Calling Blob/Clob free() explicitly after implicit free throws exception in client driver.
Changed stored  procedures to noop if the locator is already freed.


Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/LOBStoredProcedure.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/BlobTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/ClobTest.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/LOBStoredProcedure.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/LOBStoredProcedure.java?rev=1709431&r1=1709430&r2=1709431&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/LOBStoredProcedure.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/LOBStoredProcedure.java Mon Oct 19 15:41:04 2015
@@ -56,7 +56,8 @@ public class LOBStoredProcedure {
     public static void CLOBRELEASELOCATOR(int LOCATOR) throws SQLException {
         Clob clob = (Clob)getEmbedConnection().getLOBMapping(LOCATOR);
         if (clob == null) {
-            throw newSQLException(SQLState.LOB_LOCATOR_INVALID);
+            // DERBY-5605. Do not throw exception if already freed.
+            return;
         }
         EmbedClob embedClob = (EmbedClob)clob;
         embedClob.free();
@@ -223,7 +224,8 @@ public class LOBStoredProcedure {
     public static void BLOBRELEASELOCATOR(int LOCATOR) throws SQLException {
         Blob blob = (Blob)getEmbedConnection().getLOBMapping(LOCATOR);
         if (blob == null) {
-            throw newSQLException(SQLState.LOB_LOCATOR_INVALID);
+            // DERBY-5605 - noop if already released. 
+            return;
         }
         EmbedBlob embedBlob = (EmbedBlob)blob;
         embedBlob.free();

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/BlobTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/BlobTest.java?rev=1709431&r1=1709430&r2=1709431&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/BlobTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/BlobTest.java Mon Oct 19 15:41:04 2015
@@ -829,6 +829,24 @@ public class BlobTest
 
 
     /**
+     * Tests free() after implicit free
+     *
+     * @throws SQLException if an error occurs during free
+     *        
+     */
+    public void testFreeAfterImplicitFree()  throws SQLException
+    {
+        Connection conn = getConnection();
+        blob = BlobClobTestSetup.getSampleBlob(conn);
+        conn.commit();
+        // DERBY-5605
+        // free should not throw an exception even though it was 
+        // implicitly freed with the commit.
+        blob.free();
+        
+    }
+    
+    /**
      * Insert a row with a large blob into the test table.  Read the row from 
      * the database and assign the blob value to <code>blob</code>.
      * @return The id of the row that was inserted

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/ClobTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/ClobTest.java?rev=1709431&r1=1709430&r2=1709431&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/ClobTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/ClobTest.java Mon Oct 19 15:41:04 2015
@@ -189,6 +189,24 @@ public class ClobTest
     }
 
     /**
+     * Tests free() after implicit free
+     *
+     * @throws SQLException if an error occurs during free
+     *        
+     */
+    public void testFreeAfterImplicitFree()  throws SQLException
+    {
+        Connection conn = getConnection();
+        clob = BlobClobTestSetup.getSampleClob(conn);
+        conn.commit();
+        // DERBY-5605
+        // free should not throw an exception even though it was 
+        // implicitly freed with the commit.
+        clob.free();
+        
+    }
+
+    /**
      * Tests the implementation for the free() method in the
      * Clob interface.
      *