[ https://issues.apache.org/jira/browse/NIFI-769?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Joe Skora updated NIFI-769: --------------------------- Attachment: nifi-769.patch Patch attached includes unit test for ByteArrayInputStream reset() bug and the fix for the bug. > ByteCountingInputStream does not count properly if you call 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 > Attachments: nifi-769.patch > > > [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 from the byte count 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)