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 2005/04/08 00:52:25 UTC

svn commit: r160486 - jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/NIOHttpDataReceiver.java

Author: olegk
Date: Thu Apr  7 15:52:24 2005
New Revision: 160486

URL: http://svn.apache.org/viewcvs?view=rev&rev=160486
Log:
Fixed a REALLY nasty bug related to the internal buffer and isDataAvailable method

Modified:
    jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/NIOHttpDataReceiver.java

Modified: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/NIOHttpDataReceiver.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/NIOHttpDataReceiver.java?view=diff&r1=160485&r2=160486
==============================================================================
--- jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/NIOHttpDataReceiver.java (original)
+++ jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/NIOHttpDataReceiver.java Thu Apr  7 15:52:24 2005
@@ -89,6 +89,7 @@
     }
     
     protected int fillBuffer() throws IOException {
+        this.buffer.compact();
         int i = this.channel.read(this.buffer);
         this.buffer.flip();
         return i;
@@ -104,7 +105,6 @@
         }
         int noRead = 0;
         if (!this.buffer.hasRemaining()) {
-            this.buffer.clear();
             noRead = fillBuffer();
             if (noRead == -1) {
                 return -1; 
@@ -128,7 +128,6 @@
     public int read() throws IOException {
         int noRead = 0;
         if (!this.buffer.hasRemaining()) {
-            this.buffer.clear();
             noRead = fillBuffer();
             if (noRead == -1) {
                 return -1; 
@@ -181,7 +180,6 @@
                     chardecoder.decode(this.buffer, tmp, false);
                 }
                 // discard the decoded content
-                this.buffer.compact();
                 noRead = fillBuffer();
                 if (noRead == -1) {
                     retry = false;