You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by "Dan Bress (JIRA)" <ji...@apache.org> on 2015/07/16 18:02:04 UTC
[jira] [Created] (NIFI-769) ByteCountingInputStream does not count
properly if you reset() twice in a row
Dan Bress created NIFI-769:
------------------------------
Summary: ByteCountingInputStream does not count properly if you reset() twice in a row
Key: NIFI-769
URL: https://issues.apache.org/jira/browse/NIFI-769
Project: Apache NiFi
Issue Type: Bug
Components: Core Framework
Affects Versions: 0.1.0
Reporter: Dan Bress
Priority: Minor
[ByteCountingInputStream|https://github.com/apache/incubator-nifi/blob/develop/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/ByteCountingInputStream.java#L99-L103] will deduct too many bytes if you call reset() twice in a row after having called mark()
Example code here:
{code}
ByteCountingInputStream bis = new ByteCountingInputStream(inputStream);
bis.mark();
bis.read();
bis.read();
// getBytesRead() should be and is 2 at this point
bis.reset();
// getBytesRead() should be and is 0 at this point
bis.reset();
Assert.assertEquals(0, bis.getBytesRead()); // this fails, getBytesRead() is -2
{code}
Lets say you are using a very strange weird old API that someone else wrote and you can't change in your processor to parse an InputStream and that strange weird old API is calling mark and then reset twice for some unknown reason. This will result in the bytes read count in the processor being wrong.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)