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/05/14 09:34:29 UTC

[GitHub] [kafka] chia7712 commented on a change in pull request #8665: KAFKA-9984 Should fail the subscription when pattern is empty

chia7712 commented on a change in pull request #8665:
URL: https://github.com/apache/kafka/pull/8665#discussion_r425001861



##########
File path: clients/src/main/java/org/apache/kafka/clients/consumer/KafkaConsumer.java
##########
@@ -1015,8 +1015,8 @@ public void subscribe(Collection<String> topics) {
     @Override
     public void subscribe(Pattern pattern, ConsumerRebalanceListener listener) {
         maybeThrowInvalidGroupIdException();
-        if (pattern == null)
-            throw new IllegalArgumentException("Topic pattern to subscribe to cannot be null");
+        if (pattern == null || pattern.toString().equals(""))
+            throw new IllegalArgumentException("Topic pattern to subscribe to cannot be " + pattern == null ? "null" : "empty");

Review comment:
       the condition is always false if you don't add brackets.
   
   ```
   throw new IllegalArgumentException("Topic pattern to subscribe to cannot be " + (pattern == null ? "null" : "empty"));
   ```




----------------------------------------------------------------
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