CountingInputStream doesn't take into account 'skip'
Compare the AWS implementation [1] with Guava's [2]
[1] https://github.com/aws/aws-sdk-java/blob/master/src/main/java/com/amazonaws/util/CountingInputStream.java [2] https://code.google.com/p/guava-libraries/source/browse/guava/src/com/google/common/io/CountingInputStream.java
I actually ran into this when trying to use the count as a condition and hit subtle/spurious error that took many hours to debug :-(
The Guava implementation is also more robust in terms of handing mark/reset.
Hey Diwaker, thanks for reporting this problem, and for providing another implementation to reference. We'll add some tests for skip to repro the problem and make sure we're taking that method into account.
Out of curiosity, were you just using CountingInputStream to wrap some of your InputStreams, or did you turn it on through the SDK's metrics collection system property?
On Tue, May 7, 2013 at 1:38 PM, Jason Fulghum [email protected]:
Out of curiosity, were you just using CountingInputStream to wrap some of your InputStreams, or did you turn it on through the SDK's metrics collection system property?
I was using it to wrap an InputStream.
— Reply to this email directly or view it on GitHubhttps://github.com/aws/aws-sdk-java/issues/68#issuecomment-17568862 .
http://floatingsun.net
Sorry for the silence here.
CountingInputStream is only intended for internal usage by the SDK, and in reality it's only used to wrap a service response stream in order to calculate the BytesProcessed metrics. We don't suggest use this class as a general utility for your own purpose.
Feel free to reopen if you find any malfunctioning within the SDK caused by this issue.