Gregory Koshelev created KAFKA-10033:
----------------------------------------

             Summary: AdminClient should throw UnknownTopicOrPartitionException 
instead of UnknownServerException if altering configs of non-existing topic
                 Key: KAFKA-10033
                 URL: https://issues.apache.org/jira/browse/KAFKA-10033
             Project: Kafka
          Issue Type: Improvement
          Components: admin
    Affects Versions: 2.4.0
            Reporter: Gregory Koshelev


Currently, altering configs of non-existing topic leads to 
{{UnknownServerException}}:

{code}
java.util.concurrent.ExecutionException: 
org.apache.kafka.common.errors.UnknownServerException: Topic "kgn_test" does 
not exist.
        at 
org.apache.kafka.common.internals.KafkaFutureImpl.wrapAndThrow(KafkaFutureImpl.java:45)
        at 
org.apache.kafka.common.internals.KafkaFutureImpl.access$000(KafkaFutureImpl.java:32)
        at 
org.apache.kafka.common.internals.KafkaFutureImpl$SingleWaiter.await(KafkaFutureImpl.java:89)
        at 
org.apache.kafka.common.internals.KafkaFutureImpl.get(KafkaFutureImpl.java:260)
        at 
ru.kontur.vostok.hercules.stream.manager.kafka.KafkaManager.changeTtl(KafkaManager.java:130)
        ... 10 common frames omitted
Caused by: org.apache.kafka.common.errors.UnknownServerException: Topic 
"kgn_test" does not exist.
{code}

The output above is produced due to {{AdminZkClient.validateTopicConfig}} 
method:
{code}
  def validateTopicConfig(topic: String, configs: Properties): Unit = {
    Topic.validate(topic)
    if (!zkClient.topicExists(topic))
      throw new AdminOperationException("Topic \"%s\" does not 
exist.".format(topic))
    // remove the topic overrides
    LogConfig.validate(configs)
  }
{code}

{{UnknownServerException}} is common exception but in this case cause is pretty 
clear. So this can be fixed easily by using 
{{UnknownTopicOrPartitionException}}.



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

Reply via email to