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

ASF GitHub Bot commented on NIFI-1701:
--------------------------------------

Github user joewitt commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/314#discussion_r58008694
  
    --- Diff: 
nifi-nar-bundles/nifi-kafka-bundle/nifi-kafka-processors/src/main/java/org/apache/nifi/processors/kafka/StreamScanner.java
 ---
    @@ -55,29 +56,53 @@
          */
         boolean hasNext() {
             this.data = null;
    -        if (!this.eos) {
    +        int j = 0;
    +        boolean moreData = true;
    +        byte b;
    +        while (this.data == null) {
    +            this.expandBufferIfNecessary();
                 try {
    -                boolean keepReading = true;
    -                while (keepReading) {
    -                    byte b = (byte) this.is.read();
    -                    if (b > -1) {
    -                        baos.write(b);
    -                        if (buffer.addAndCompare(b)) {
    -                            this.data = 
Arrays.copyOfRange(baos.getUnderlyingBuffer(), 0, baos.size() - 
delimiter.length);
    -                            keepReading = false;
    -                        }
    -                    } else {
    -                        this.data = baos.toByteArray();
    -                        keepReading = false;
    -                        this.eos = true;
    +                b = (byte) this.is.read();
    --- End diff --
    
    is.read() returns an int and -1 and represents end of stream.  Once that 
has been verified can the byte value as represented in the range of 0 to 255.  
Will submit a patch containing a test that proves it is broken and will make 
the fix.


> StreamScanner in PutKafka doesn't handle byte values < -1 properly
> ------------------------------------------------------------------
>
>                 Key: NIFI-1701
>                 URL: https://issues.apache.org/jira/browse/NIFI-1701
>             Project: Apache NiFi
>          Issue Type: Bug
>            Reporter: Oleg Zhurakousky
>            Assignee: Oleg Zhurakousky
>            Priority: Critical
>             Fix For: 0.7.0
>
>




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to