You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by "Mark Payne (JIRA)" <ji...@apache.org> on 2015/07/20 17:40:04 UTC

[jira] [Commented] (NIFI-769) ByteCountingInputStream does not count properly if you call reset() twice in a row

    [ https://issues.apache.org/jira/browse/NIFI-769?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14633708#comment-14633708 ] 

Mark Payne commented on NIFI-769:
---------------------------------

Patch looks good. Applied and all still works, including the new unit tests. +1.

Merged to develop.

> 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
>            Assignee: Mark Payne
>            Priority: Minor
>             Fix For: 0.3.0
>
>         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)