You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@nifi.apache.org by olegz <gi...@git.apache.org> on 2016/03/31 07:00:21 UTC

[GitHub] nifi pull request: NIFI-1701 fixed StreamScanner, added more tests

GitHub user olegz opened a pull request:

    https://github.com/apache/nifi/pull/314

    NIFI-1701 fixed StreamScanner, added more tests

    

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/olegz/nifi NIFI-1701

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/nifi/pull/314.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #314
    
----
commit bab1881abe462a022c98e53d21ee6c2cce91f395
Author: Oleg Zhurakousky <ol...@suitcase.io>
Date:   2016-03-31T04:59:26Z

    NIFI-1701 fixed StreamScanner, added more tests

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi pull request: NIFI-1701 fixed StreamScanner, added more tests

Posted by olegz <gi...@git.apache.org>.
Github user olegz closed the pull request at:

    https://github.com/apache/nifi/pull/314


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi pull request: NIFI-1701 fixed StreamScanner, added more tests

Posted by joewitt <gi...@git.apache.org>.
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.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---