You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2020/10/05 16:51:09 UTC

[GitHub] [kafka] C0urante opened a new pull request #9375: KAFKA-10574: Fix infinite loop in Values::parseString

C0urante opened a new pull request #9375:
URL: https://github.com/apache/kafka/pull/9375


   [Jira](https://issues.apache.org/jira/browse/KAFKA-10574)
   
   The special byte sequence `0xEF, 0xBF, 0xBF`, when parsed as a UTF-8 string, causes the `StringCharacterIterator` to return `CharacterIterator.DONE` from its `next()`, `current()`, and other similar methods. This caused an infinite loop in the `Values` class whenever that byte sequence was encountered.
   
   The fix is pretty simple. To see if we're at the end of a string, we compare `StandardCharacterIterator::getIndex` to `StandardCharacterIterator::getEndIndex`, instead of comparing the last-read character to `CharacterIterator.DONE` (since that character may occur in strings that we're parsing).
   
   I've added a unit test that replicates this bug (when the fix in the `Values` class is not present). I gave it a timeout of five seconds in case someone accidentally re-creates the infinite loop in order to save some time and potential confusion.
   
   All existing unit tests for the `Values` class pass with this change.
   ### Committer Checklist (excluded from commit message)
   - [ ] Verify design and implementation 
   - [ ] Verify test coverage and CI build status
   - [ ] Verify documentation (including upgrade notes)
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kafka] C0urante commented on a change in pull request #9375: KAFKA-10574: Fix infinite loop in Values::parseString

Posted by GitBox <gi...@apache.org>.
C0urante commented on a change in pull request #9375:
URL: https://github.com/apache/kafka/pull/9375#discussion_r499754411



##########
File path: connect/api/src/test/java/org/apache/kafka/connect/data/ValuesTest.java
##########
@@ -73,6 +76,15 @@
         INT_LIST.add(-987654321);
     }
 
+    @Test(timeout = 5000)
+    public void shouldNotEncounterInfiniteLoop() {
+        byte[] bytes = new byte[] { -17, -65,  -65 };

Review comment:
       👍   good call, will add 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kafka] C0urante commented on pull request #9375: KAFKA-10574: Fix infinite loop in Values::parseString

Posted by GitBox <gi...@apache.org>.
C0urante commented on pull request #9375:
URL: https://github.com/apache/kafka/pull/9375#issuecomment-705596382


   Hi @rhauch @kkonstantine, this PR has been approved, all merge conflicts have been resolved, and every build is green. Would it be possible to merge sometime soon so that it can be backported to bug fix releases and avoid accruing merge conflicts in case the files touched here are modified in other PRs? Thanks!


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kafka] kkonstantine commented on a change in pull request #9375: KAFKA-10574: Fix infinite loop in Values::parseString

Posted by GitBox <gi...@apache.org>.
kkonstantine commented on a change in pull request #9375:
URL: https://github.com/apache/kafka/pull/9375#discussion_r499750739



##########
File path: connect/api/src/test/java/org/apache/kafka/connect/data/ValuesTest.java
##########
@@ -73,6 +76,15 @@
         INT_LIST.add(-987654321);
     }
 
+    @Test(timeout = 5000)
+    public void shouldNotEncounterInfiniteLoop() {
+        byte[] bytes = new byte[] { -17, -65,  -65 };

Review comment:
       we need a comment here to explain things. 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kafka] rhauch merged pull request #9375: KAFKA-10574: Fix infinite loop in Values::parseString

Posted by GitBox <gi...@apache.org>.
rhauch merged pull request #9375:
URL: https://github.com/apache/kafka/pull/9375


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kafka] C0urante commented on pull request #9375: KAFKA-10574: Fix infinite loop in Values::parseString

Posted by GitBox <gi...@apache.org>.
C0urante commented on pull request #9375:
URL: https://github.com/apache/kafka/pull/9375#issuecomment-703756981


   @rhauch @kkonstantine can one of you take a look?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kafka] C0urante commented on pull request #9375: KAFKA-10574: Fix infinite loop in Values::parseString

Posted by GitBox <gi...@apache.org>.
C0urante commented on pull request #9375:
URL: https://github.com/apache/kafka/pull/9375#issuecomment-705596382


   Hi @rhauch @kkonstantine, this PR has been approved, all merge conflicts have been resolved, and every build is green. Would it be possible to merge sometime soon so that it can be backported to bug fix releases and avoid accruing merge conflicts in case the files touched here are modified in other PRs? Thanks!


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kafka] C0urante commented on a change in pull request #9375: KAFKA-10574: Fix infinite loop in Values::parseString

Posted by GitBox <gi...@apache.org>.
C0urante commented on a change in pull request #9375:
URL: https://github.com/apache/kafka/pull/9375#discussion_r499754411



##########
File path: connect/api/src/test/java/org/apache/kafka/connect/data/ValuesTest.java
##########
@@ -73,6 +76,15 @@
         INT_LIST.add(-987654321);
     }
 
+    @Test(timeout = 5000)
+    public void shouldNotEncounterInfiniteLoop() {
+        byte[] bytes = new byte[] { -17, -65,  -65 };

Review comment:
       👍  good call, will add




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kafka] C0urante commented on pull request #9375: KAFKA-10574: Fix infinite loop in Values::parseString

Posted by GitBox <gi...@apache.org>.
C0urante commented on pull request #9375:
URL: https://github.com/apache/kafka/pull/9375#issuecomment-703775022


   Thanks @kkonstantine, I've added a comment and addressed the Checkstyle issues.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org