db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From krist...@apache.org
Subject svn commit: r725286 - in /db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/jdbc: EmbedBlob.java PositionedStoreStream.java StoreStreamClob.java
Date Wed, 10 Dec 2008 14:02:31 GMT
Author: kristwaa
Date: Wed Dec 10 06:02:30 2008
New Revision: 725286

URL: http://svn.apache.org/viewvc?rev=725286&view=rev
Log:
DERBY-3970: PositionedStoreStream doesn't initialize itself properly.
Merged revision 722812 from trunk.

Modified:
    db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/jdbc/EmbedBlob.java
    db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/jdbc/PositionedStoreStream.java
    db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/jdbc/StoreStreamClob.java

Modified: db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/jdbc/EmbedBlob.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/jdbc/EmbedBlob.java?rev=725286&r1=725285&r2=725286&view=diff
==============================================================================
--- db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/jdbc/EmbedBlob.java (original)
+++ db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/jdbc/EmbedBlob.java Wed
Dec 10 06:02:30 2008
@@ -196,18 +196,8 @@
             }
             // Create a position aware stream on top of dvdStream so we can
             // more easily move back and forth in the Blob.
-            myStream = new PositionedStoreStream(dvdStream);
-            try {
-                myStream.initStream();
-            } catch (StandardException se) {
-                if (se.getMessageId().equals(SQLState.DATA_CONTAINER_CLOSED)) {
-                    throw StandardException
-                            .newException(SQLState.BLOB_ACCESSED_AFTER_COMMIT);
-                } else {
-                    throw se;
-                }
-            }
             try {
+                myStream = new PositionedStoreStream(dvdStream);
                 // The BinaryToRawStream will read the encoded length bytes.
                 BinaryToRawStream tmpStream =
                         new BinaryToRawStream(myStream, con);
@@ -215,9 +205,16 @@
                 // Check up front if the stream length is specified.
                 streamLength = tmpStream.getLength();
                 tmpStream.close();
+            } catch (StandardException se) {
+                if (se.getMessageId().equals(SQLState.DATA_CONTAINER_CLOSED)) {
+                    throw StandardException
+                            .newException(SQLState.BLOB_ACCESSED_AFTER_COMMIT);
+                } else {
+                    throw se;
+                }
             } catch (IOException ioe) {
                 throw StandardException.newException(
-                        SQLState.LANG_STREAMING_COLUMN_I_O_EXCEPTION, ioe);
+                     SQLState.LANG_STREAMING_COLUMN_I_O_EXCEPTION, ioe, "BLOB");
             }
         }
         //add entry in connection so it can be cleared 

Modified: db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/jdbc/PositionedStoreStream.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/jdbc/PositionedStoreStream.java?rev=725286&r1=725285&r2=725286&view=diff
==============================================================================
--- db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/jdbc/PositionedStoreStream.java
(original)
+++ db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/jdbc/PositionedStoreStream.java
Wed Dec 10 06:02:30 2008
@@ -73,11 +73,18 @@
     /**
      * Creates a positioned store stream on top of the specified resettable
      * stream.
+     * <p>
+     * Upon creation, the underlying stream is initiated and reset to make
+     * sure the states of the streams are in sync with each other.
      *
      * @param in a {@link Resetable}-stream
      */
-    public PositionedStoreStream(InputStream in) {
+    public PositionedStoreStream(InputStream in)
+            throws IOException, StandardException {
         this.stream = in;
+        // We need to know the stream is in a consistent state.
+        ((Resetable)in).initStream();
+        ((Resetable)in).resetStream();
     }
 
     /**
@@ -160,7 +167,6 @@
     public void initStream()
             throws StandardException {
         ((Resetable)this.stream).initStream();
-        this.pos = 0L;
     }
 
     /**

Modified: db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/jdbc/StoreStreamClob.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/jdbc/StoreStreamClob.java?rev=725286&r1=725285&r2=725286&view=diff
==============================================================================
--- db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/jdbc/StoreStreamClob.java
(original)
+++ db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/jdbc/StoreStreamClob.java
Wed Dec 10 06:02:30 2008
@@ -113,10 +113,21 @@
      */
     public StoreStreamClob(InputStream stream, ConnectionChild conChild)
             throws StandardException {
-        this.positionedStoreStream = new PositionedStoreStream(stream);
+        try {
+            this.positionedStoreStream = new PositionedStoreStream(stream);
+        } catch (StandardException se) {
+            if (se.getMessageId().equals(SQLState.DATA_CONTAINER_CLOSED)) {
+                throw StandardException
+                        .newException(SQLState.BLOB_ACCESSED_AFTER_COMMIT);
+            } else {
+                throw se;
+            }
+        } catch (IOException ioe) {
+            throw StandardException.newException(
+                    SQLState.LANG_STREAMING_COLUMN_I_O_EXCEPTION, ioe, "CLOB");
+        }
         this.conChild = conChild;
         this.synchronizationObject = conChild.getConnectionSynchronization();
-        this.positionedStoreStream.initStream();
     }
 
     /**



Mime
View raw message