You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@kafka.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2017/06/03 06:52:04 UTC

[jira] [Commented] (KAFKA-5098) KafkaProducer.send() blocks and generates TimeoutException if topic name has illegal char

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

ASF GitHub Bot commented on KAFKA-5098:
---------------------------------------

GitHub user huxihx opened a pull request:

    https://github.com/apache/kafka/pull/3223

    KAFKA-5098: KafkaProducer.send() should validate topic name before sending

    KafkaProducer.send() should check topic name before sending the record.

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

    $ git pull https://github.com/huxihx/kafka KAFKA-5098_Does_not_check_topic_name_before_sending

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

    https://github.com/apache/kafka/pull/3223.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 #3223
    
----
commit b457518b55f8f7c32ca5e6849fa4052b596c98e1
Author: huxihx <hu...@hotmail.com>
Date:   2017-06-03T06:50:05Z

    KAFKA-5098: KafkaProducer.send() blocks and generates TimeoutException if topic name has illegal char
    
    Validate topic name before sending the record

----


> KafkaProducer.send() blocks and generates TimeoutException if topic name has illegal char
> -----------------------------------------------------------------------------------------
>
>                 Key: KAFKA-5098
>                 URL: https://issues.apache.org/jira/browse/KAFKA-5098
>             Project: Kafka
>          Issue Type: Bug
>          Components: producer 
>    Affects Versions: 0.10.2.0
>         Environment: Java client running against server using wurstmeister/kafka Docker image.
>            Reporter: Jeff Larsen
>
> The server is running with auto create enabled. If we try to publish to a topic with a forward slash in the name, the call blocks and we get a TimeoutException in the Callback. I would expect it to return immediately with an InvalidTopicException.
> There are other blocking issues that have been reported which may be related to some degree, but this particular cause seems unrelated.
> Sample code:
> {code}
> import org.apache.kafka.clients.producer.*;
> import java.util.*;
> public class KafkaProducerUnexpectedBlockingAndTimeoutException {
>   public static void main(String[] args) {
>     Properties props = new Properties();
>     props.put("bootstrap.servers", "kafka.example.com:9092");
>     props.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer");
>     props.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer");
>     props.put("max.block.ms", 10000); // 10 seconds should illustrate our point
>     String separator = "/";
>     //String separator = "_";
>     try (Producer<String, String> producer = new KafkaProducer<>(props)) {
>       System.out.println("Calling KafkaProducer.send() at " + new Date());
>       producer.send(
>           new ProducerRecord<String, String>("abc" + separator + "someStreamName",
>               "Not expecting a TimeoutException here"),
>           new Callback() {
>             @Override
>             public void onCompletion(RecordMetadata metadata, Exception e) {
>               if (e != null) {
>                 System.out.println(e.toString());
>               }
>             }
>           });
>       System.out.println("KafkaProducer.send() completed at " + new Date());
>     }
>   }
> }
> {code}
> Switching to the underscore separator in the above example works as expected.
> Mea culpa: We neglected to research allowed chars in a topic name, but the TimeoutException we encountered did not help point us in the right direction.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)