You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "Chris Egerton (Jira)" <ji...@apache.org> on 2020/10/05 16:19:00 UTC

[jira] [Comment Edited] (KAFKA-10574) Infinite loop in SimpleHeaderConverter and Values classes

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

Chris Egerton edited comment on KAFKA-10574 at 10/5/20, 4:18 PM:
-----------------------------------------------------------------

This can be reproduced by adding the following test case to the {{ValuesTest}} class (beware that running this test will cause an infinite loop and it will need to be terminated manually):

{code:java}
    @Test
    public void shouldNotEncounterInfiniteLoop() {
        byte[] bytes = new byte[] { -17, -65,  -65 };
        String str = new String(bytes, StandardCharsets.UTF_8);
        Values.parseString(str);
    }
{code}



was (Author: chrisegerton):
This can be reproduced by adding the following test case to the {{ValuesTest}} class:

 
{code:java}
    @Test
    public void shouldNotEncounterInfiniteLoop() {
        byte[] bytes = new byte[] { -17, -65,  -65 };
        String str = new String(bytes, StandardCharsets.UTF_8);
        Values.parseString(str);
    }
{code}


> Infinite loop in SimpleHeaderConverter and Values classes
> ---------------------------------------------------------
>
>                 Key: KAFKA-10574
>                 URL: https://issues.apache.org/jira/browse/KAFKA-10574
>             Project: Kafka
>          Issue Type: Bug
>          Components: KafkaConnect
>    Affects Versions: 1.1.0, 1.1.1, 1.1.2, 2.0.0, 2.0.1, 2.1.0, 2.2.0, 2.1.1, 2.0.2, 2.3.0, 2.2.1, 2.2.2, 2.4.0, 2.3.1, 2.5.0, 2.4.1, 2.6.0, 2.5.1
>            Reporter: Chris Egerton
>            Assignee: Chris Egerton
>            Priority: Major
>
> A header value with the byte sequence {{0xEF, 0xBF, 0xBF}} will cause an infinite loop in the {{Values::parseString}} method. Since that method is invoked by the default header converter ({{SimpleHeaderConverter}}), any sink record with that byte array will, by default, cause a sink task reading that record to stall forever.
> This occurs because that byte sequence, when parsed as a UTF-8 string and then read by a [StringCharacterIterator|https://docs.oracle.com/javase/8/docs/api/java/text/StringCharacterIterator.html], causes the [CharacterIterator.DONE|https://docs.oracle.com/javase/8/docs/api/java/text/CharacterIterator.html#DONE] character to be returned from [StringCharacterIterator::current|https://docs.oracle.com/javase/8/docs/api/java/text/StringCharacterIterator.html#current--], [StringCharacterIterator::next|https://docs.oracle.com/javase/8/docs/api/java/text/StringCharacterIterator.html#next--], etc., and a check for that character is used by the {{Values}} class for its parsing logic.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)