db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From krist...@apache.org
Subject svn commit: r673064 - in /db/derby/code/branches/10.3/java: engine/org/apache/derby/impl/jdbc/ testing/org/apache/derbyTesting/functionTests/tests/store/ testing/org/apache/derbyTesting/functionTests/util/streams/
Date Tue, 01 Jul 2008 12:04:55 GMT
Author: kristwaa
Date: Tue Jul  1 05:04:55 2008
New Revision: 673064

URL: http://svn.apache.org/viewvc?rev=673064&view=rev
Log:
DERBY-3735: Incorrect position calculation in PositionedStoreStream with read(byte[],...).
Backported revisions 671840 and 672284 from trunk (10.5).

Added:
    db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/store/PositionedStoreStreamTest.java
      - copied unchanged from r671840, db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/PositionedStoreStreamTest.java
Modified:
    db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/jdbc/PositionedStoreStream.java
    db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/store/_Suite.java
    db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/util/streams/LoopingAlphabetStream.java

Modified: db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/jdbc/PositionedStoreStream.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/jdbc/PositionedStoreStream.java?rev=673064&r1=673063&r2=673064&view=diff
==============================================================================
--- db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/jdbc/PositionedStoreStream.java
(original)
+++ db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/jdbc/PositionedStoreStream.java
Tue Jul  1 05:04:55 2008
@@ -96,9 +96,7 @@
      */
     public int read(byte[] b)
             throws IOException {
-        int ret = this.stream.read(b);
-        this.pos += ret;
-        return ret;
+        return read(b, 0, b.length);
     }
 
     /**
@@ -112,7 +110,9 @@
     public int read(byte[] b, int off, int len)
             throws IOException {
         int ret = this.stream.read(b, off, len);
-        this.pos += ret;
+        if (ret > -1) {
+            this.pos += ret;
+        }
         return ret;
     }
 

Modified: db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/store/_Suite.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/store/_Suite.java?rev=673064&r1=673063&r2=673064&view=diff
==============================================================================
--- db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/store/_Suite.java
(original)
+++ db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/store/_Suite.java
Tue Jul  1 05:04:55 2008
@@ -54,6 +54,7 @@
         suite.addTest(BootAllTest.suite());
 
         suite.addTest(Derby3625Test.suite());
+        suite.addTest(PositionedStoreStreamTest.suite());
         // Encryption only supported for Derby in J2SE/J2EE environments.
         // J2ME (JSR169) does not support encryption.
         if (JDBC.vmSupportsJDBC3()) {

Modified: db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/util/streams/LoopingAlphabetStream.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/util/streams/LoopingAlphabetStream.java?rev=673064&r1=673063&r2=673064&view=diff
==============================================================================
--- db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/util/streams/LoopingAlphabetStream.java
(original)
+++ db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/util/streams/LoopingAlphabetStream.java
Tue Jul  1 05:04:55 2008
@@ -22,14 +22,16 @@
 package org.apache.derbyTesting.functionTests.util.streams;
 
 import java.io.InputStream;
-import java.io.IOException;
+
+import org.apache.derby.iapi.types.Resetable;
 
 /**
  * A stream returning a cycle of the 26 lowercase letters of the modern Latin
  * alphabet.
  */
 public class LoopingAlphabetStream
-    extends InputStream {
+    extends InputStream
+    implements Resetable {
 
     /**
      * Maximum size of buffer.
@@ -56,7 +58,18 @@
         this(length, 0);
     }
 
+    /**
+     * Creates a looping alphabet stream with the specified length, in which the
+     * last characters are blanks.
+     *
+     * @param length total length of the stream
+     * @param trailingBlanks number of trailing blanks
+     */
     public LoopingAlphabetStream(long length, int trailingBlanks) {
+        if (trailingBlanks > length) {
+            throw new IllegalArgumentException("Number of trailing blanks " +
+                    "cannot be greater than the total length.");
+        }
         this.length = length;
         this.trailingBlanks = trailingBlanks;
         this.remainingNonBlanks = length - trailingBlanks;
@@ -184,4 +197,18 @@
         }
         return i;
     }
+
+    // Resetable interface
+
+    public void resetStream() {
+        reset();
+    }
+
+    public void initStream() {
+        reset();
+    }
+
+    public void closeStream() {
+        // Does nothing for this stream.
+    }
 } // End class LoopingAlphabetStream



Mime
View raw message