db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From krist...@apache.org
Subject svn commit: r542005 - in /db/derby/code/trunk/java: drda/org/apache/derby/impl/drda/EXTDTAInputStream.java engine/org/apache/derby/iapi/services/io/NewByteArrayInputStream.java engine/org/apache/derby/impl/store/raw/data/BufferedByteHolderInputStream.java
Date Sun, 27 May 2007 17:22:36 GMT
Author: kristwaa
Date: Sun May 27 10:22:35 2007
New Revision: 542005

URL: http://svn.apache.org/viewvc?view=rev&rev=542005
Log:
DERBY-2686: Brushed up two skip methods; one to return 0 when a negative amount to skip is
passed in, the other one will now break when 0 is returned from the underlying stream. No
assumption is made about EOF, this is still up to the higher level streams, but the skip method
will no longer hang forever if there is less bytes than requested in skip. Also removed some
unused imports.
Patch file: derby-2686-3a.diff

Modified:
    db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/EXTDTAInputStream.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/NewByteArrayInputStream.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/BufferedByteHolderInputStream.java

Modified: db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/EXTDTAInputStream.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/EXTDTAInputStream.java?view=diff&rev=542005&r1=542004&r2=542005
==============================================================================
--- db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/EXTDTAInputStream.java (original)
+++ db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/EXTDTAInputStream.java Sun May
27 10:22:35 2007
@@ -20,7 +20,6 @@
  */
 package org.apache.derby.impl.drda;
 
-import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.BufferedInputStream;
@@ -29,8 +28,6 @@
 import java.sql.Clob;
 import java.sql.SQLException;
 
-import java.io.UnsupportedEncodingException;
-
 import org.apache.derby.iapi.reference.DRDAConstants;
 import org.apache.derby.iapi.services.sanity.SanityManager;
 import org.apache.derby.impl.jdbc.Util;
@@ -252,6 +249,9 @@
 	 * @see java.io.InputStream#skip(long)
 	 */
 	public long skip(long arg0) throws IOException {
+		if (arg0 < 0L) {
+			return 0L;
+		}
 		return binaryInputStream.skip(arg0);
 	}
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/NewByteArrayInputStream.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/NewByteArrayInputStream.java?view=diff&rev=542005&r1=542004&r2=542005
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/NewByteArrayInputStream.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/NewByteArrayInputStream.java
Sun May 27 10:22:35 2007
@@ -81,8 +81,9 @@
 		if (data == null)
 			throw new IOException();
 
-		if (length == 0)
-			return -1;
+		if (length == 0 || count <= 0L) {
+			return 0L;
+		}
 
 		if (count > length)
 			count = length;

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/BufferedByteHolderInputStream.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/BufferedByteHolderInputStream.java?view=diff&rev=542005&r1=542004&r2=542005
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/BufferedByteHolderInputStream.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/BufferedByteHolderInputStream.java
Sun May 27 10:22:35 2007
@@ -21,7 +21,6 @@
 
 package org.apache.derby.impl.store.raw.data;
 
-import java.io.InputStream;
 import java.io.IOException;
 
 public abstract class BufferedByteHolderInputStream
@@ -48,10 +47,14 @@
 
 	public long skip(long count) throws IOException
 	{
-		int bytesSkipped = 0;
+		long bytesSkipped = 0L;
 		while (bytesSkipped < count) {
 			fillByteHolder();
-			bytesSkipped += super.skip(count - bytesSkipped);
+			long skipped = super.skip(count - bytesSkipped);
+			if (skipped <= 0L) {
+				break;
+			}
+			bytesSkipped += skipped;
 		}
 		return bytesSkipped;
 	}



Mime
View raw message