Skip to content

Commit

Permalink
Improve InvalidTopicName Error message (apache#7609)
Browse files Browse the repository at this point in the history
Co-authored-by: Sanjeev Kulkarni <[email protected]>
  • Loading branch information
srkukarni and Sanjeev Kulkarni authored Jul 24, 2020
1 parent ff4c3f6 commit e21db6e
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,10 @@ public <T> CompletableFuture<Consumer<T>> subscribeAsync(ConsumerConfigurationDa
new PulsarClientException.InvalidConfigurationException("Consumer configuration undefined"));
}

if (!conf.getTopicNames().stream().allMatch(TopicName::isValid)) {
return FutureUtil.failedFuture(new PulsarClientException.InvalidTopicNameException("Invalid topic name"));
for (String topic : conf.getTopicNames()) {
if (!TopicName.isValid(topic)) {
return FutureUtil.failedFuture(new PulsarClientException.InvalidTopicNameException("Invalid topic name: '" + topic + "'"));
}
}

if (isBlank(conf.getSubscriptionName())) {
Expand Down Expand Up @@ -469,7 +471,7 @@ <T> CompletableFuture<Reader<T>> doCreateReaderAsync(ReaderConfigurationData<T>
String topic = conf.getTopicName();

if (!TopicName.isValid(topic)) {
return FutureUtil.failedFuture(new PulsarClientException.InvalidTopicNameException("Invalid topic name"));
return FutureUtil.failedFuture(new PulsarClientException.InvalidTopicNameException("Invalid topic name: '" + topic + "'"));
}

if (conf.getStartMessageId() == null) {
Expand Down Expand Up @@ -526,7 +528,7 @@ public CompletableFuture<Optional<SchemaInfo>> getSchema(String topic) {
topicName = TopicName.get(topic);
} catch (Throwable t) {
return FutureUtil
.failedFuture(new PulsarClientException.InvalidTopicNameException("Invalid topic name: " + topic));
.failedFuture(new PulsarClientException.InvalidTopicNameException("Invalid topic name: '" + topic + "'"));
}

return lookup.getSchema(topicName);
Expand Down

0 comments on commit e21db6e

Please sign in to comment.