db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From krist...@apache.org
Subject svn commit: r722812 - in /db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc: EmbedBlob.java PositionedStoreStream.java StoreStreamClob.java
Date Wed, 03 Dec 2008 08:54:12 GMT
Author: kristwaa
Date: Wed Dec  3 00:54:12 2008
New Revision: 722812

URL: http://svn.apache.org/viewvc?rev=722812&view=rev
Log:
DERBY-3970: PositionedStoreStream doesn't initialize itself properly.
Makes PositionedStoreStream initialize itself properly by calling initStream and resetStream
on the underlying Resetable.
Patch file: derby-3970-1a-PositionedStoreStream_init.diff


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

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedBlob.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedBlob.java?rev=722812&r1=722811&r2=722812&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedBlob.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedBlob.java Wed Dec  3 00:54:12
2008
@@ -195,18 +195,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);
@@ -214,9 +204,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/trunk/java/engine/org/apache/derby/impl/jdbc/PositionedStoreStream.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/PositionedStoreStream.java?rev=722812&r1=722811&r2=722812&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/PositionedStoreStream.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/PositionedStoreStream.java
Wed Dec  3 00:54:12 2008
@@ -76,11 +76,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();
     }
 
     /**
@@ -163,7 +170,6 @@
     public void initStream()
             throws StandardException {
         ((Resetable)this.stream).initStream();
-        this.pos = 0L;
     }
 
     /**

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/StoreStreamClob.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/StoreStreamClob.java?rev=722812&r1=722811&r2=722812&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/StoreStreamClob.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/StoreStreamClob.java Wed Dec
 3 00:54:12 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