hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r927019 - in /httpcomponents/httpcore/trunk/httpcore-nio/src: main/java/org/apache/http/impl/nio/codecs/LengthDelimitedDecoder.java test/java/org/apache/http/impl/nio/codecs/TestLengthDelimitedDecoder.java
Date Wed, 24 Mar 2010 11:52:43 GMT
Author: olegk
Date: Wed Mar 24 11:52:43 2010
New Revision: 927019

URL: http://svn.apache.org/viewvc?rev=927019&view=rev
Log:
Make sure decoder returns -1 if set to completed and no bytes have been read

Modified:
    httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedDecoder.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestLengthDelimitedDecoder.java

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=927019&r1=927018&r2=927019&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
Wed Mar 24 11:52:43 2010
@@ -103,7 +103,11 @@ public class LengthDelimitedDecoder exte
         if (this.len >= this.contentLength) {
             this.completed = true;
         }
-        return bytesRead;
+        if (this.completed && bytesRead == 0) {
+            return -1;
+        } else {
+            return bytesRead;
+        }
     }
     
     public long transfer(

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestLengthDelimitedDecoder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestLengthDelimitedDecoder.java?rev=927019&r1=927018&r2=927019&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestLengthDelimitedDecoder.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestLengthDelimitedDecoder.java
Wed Mar 24 11:52:43 2010
@@ -523,7 +523,7 @@ public class TestLengthDelimitedDecoder 
         ByteBuffer dst = ByteBuffer.allocate(1024); 
         
         int bytesRead = decoder.read(dst);
-        assertEquals(0, bytesRead);
+        assertEquals(-1, bytesRead);
         assertTrue(decoder.isCompleted());
         assertEquals(0, metrics.getBytesTransferred());
     }



Mime
View raw message