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

ASF subversion and git services commented on NIFI-4856:
-------------------------------------------------------

Commit 336d3cf1f2641bdf72e8f1847f16f01d4780b186 in nifi's branch 
refs/heads/master from [~alopresto]
[ https://git-wip-us.apache.org/repos/asf?p=nifi.git;h=336d3cf ]

NIFI-4856 Removed deprecated ByteArrayInputStream references in 
ByteCountingInputStreamTest.
Added failing unit test for #available() at various states (initial, during 
read, after read).
Implemented #available() delegation.
All tests pass.

This closes #2461.

Signed-off-by: Kevin Doran <kdo...@apache.org>


> ByteCountingInputStream should override available()
> ---------------------------------------------------
>
>                 Key: NIFI-4856
>                 URL: https://issues.apache.org/jira/browse/NIFI-4856
>             Project: Apache NiFi
>          Issue Type: Bug
>    Affects Versions: 1.5.0
>            Reporter: Brandon DeVries
>            Assignee: Andy LoPresto
>            Priority: Major
>
> ByteCountingInputStream [1] does not override the InputStream.available() 
> method as indicated in the InputStream javadocs [2].  In 0.x[3] there was 
> another implementation of ByteCountingInputStream  that correctly overrode 
> available().  However, this was replaced with the incorrect version in 1.x. 
>  
> This causes any processor that attempts to use the available() method of the 
> InputStream returned from ProcessSession.read() to erroneously believe it has 
> reached the end of the stream, as this method is supposed to return "an 
> estimate of the number of bytes that can be read (or skipped over) from this 
> input stream without blocking *or {{0}} when it reaches the end* of the input 
> stream."
>  
> The following method needs to be added:
> {code:java}
> @Override
> public int available() throws IOException {
>      return in.available();
> }{code}
>  
> [1] 
> [https://github.com/apache/nifi/blob/rel/nifi-1.5.0/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/ByteCountingInputStream.java]
> [2] [https://docs.oracle.com/javase/8/docs/api/index.html]
> [3] 
> [https://github.com/apache/nifi/blob/0.x/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/repository/io/ByteCountingInputStream.java]
>  
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to