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: us...@infra.apache.org