You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2012/02/05 15:31:28 UTC
svn commit: r1240740 - in
/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs:
IdentityDecoder.java LengthDelimitedDecoder.java
Author: olegk
Date: Sun Feb 5 14:31:27 2012
New Revision: 1240740
URL: http://svn.apache.org/viewvc?rev=1240740&view=rev
Log:
Better (hopefully) exception message in LengthDelimitedDecoder and IdentityDecoder in case an attempt is made to write past end of file
Modified:
httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/IdentityDecoder.java
httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedDecoder.java
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/IdentityDecoder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/IdentityDecoder.java?rev=1240740&r1=1240739&r2=1240740&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/IdentityDecoder.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/IdentityDecoder.java Sun Feb 5 14:31:27 2012
@@ -39,7 +39,7 @@ import org.apache.http.nio.reactor.Sessi
/**
* Content decoder that reads data without any transformation. The end of the
- * content entity is demarcated by closing the underlying connection
+ * content entity is delineated by closing the underlying connection
* (EOF condition). Entities transferred using this input stream can be of
* unlimited length.
* <p>
@@ -112,11 +112,10 @@ public class IdentityDecoder extends Abs
bytesRead = this.buffer.read(dst);
} else {
if (this.channel.isOpen()) {
- if(dst.size() < position)
- throw new IOException("FileChannel.size() [" + dst.size() +
- "] < position [" + position +
- "]. Please grow the file before writing.");
-
+ if (position > dst.size()) {
+ throw new IOException("Position past end of file [" + position +
+ " > " + dst.size() + "]");
+ }
bytesRead = dst.transferFrom(this.channel, position, count);
if (bytesRead == 0) {
bytesRead = buffer.fill(this.channel);
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedDecoder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedDecoder.java?rev=1240740&r1=1240739&r2=1240740&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedDecoder.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedDecoder.java Sun Feb 5 14:31:27 2012
@@ -141,11 +141,10 @@ public class LengthDelimitedDecoder exte
count = chunk;
}
if (this.channel.isOpen()) {
- if(dst.size() < position)
- throw new IOException("FileChannel.size() [" + dst.size() +
- "] < position [" + position +
- "]. Please grow the file before writing.");
-
+ if (position > dst.size()) {
+ throw new IOException("Position past end of file [" + position +
+ " > " + dst.size() + "]");
+ }
bytesRead = dst.transferFrom(this.channel, position, count);
} else {
bytesRead = -1;