[ 
https://issues.apache.org/jira/browse/HTTPCORE-174?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12636385#action_12636385
 ] 

Ildar Safarov commented on HTTPCORE-174:
----------------------------------------

I think this change in the test will expose the bug:

Index: 
module-main/src/test/java/org/apache/http/impl/io/TestContentLengthInputStream.java
===================================================================
--- 
module-main/src/test/java/org/apache/http/impl/io/TestContentLengthInputStream.java
 (revision 701108)
+++ 
module-main/src/test/java/org/apache/http/impl/io/TestContentLengthInputStream.java
 (working copy)
@@ -114,6 +114,10 @@
         in = new ContentLengthInputStream(new SessionInputBufferMockup(new 
byte[2]), 4L);
         in.read();
         assertTrue(in.skip(2) == 1);
+        
+        in = new ContentLengthInputStream(new SessionInputBufferMockup(new 
byte[20]), 10L);
+        in.skip(5);
+        assertEquals(5, in.read(new byte[20]));
     }
 
     public void testClose() throws IOException {


> Position is incremented twice in skip(long) method of ContentLengthInputStream
> ------------------------------------------------------------------------------
>
>                 Key: HTTPCORE-174
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-174
>             Project: HttpComponents HttpCore
>          Issue Type: Bug
>          Components: HttpCore
>    Affects Versions: 4.0-beta2
>            Reporter: Ildar Safarov
>             Fix For: 4.0-beta3
>
>
> Position is modificated in read method inside cycle and explicitly after 
> cycle. I think patch should look like this:
> Index: ContentLengthInputStream.java
> ===================================================================
> --- ContentLengthInputStream.java     (revision 700438)
> +++ ContentLengthInputStream.java     (working copy)
> @@ -214,7 +214,6 @@
>              count += l;
>              remaining -= l;
>          }
> -        this.pos += count;
>          return count;
>      }
>  }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to