Improve InvalidTopicName Error message
@@ -302,8 +302,10 @@ public class PulsarClientImpl implements PulsarClient {
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())) {
@@ -469,7 +471,7 @@ public class PulsarClientImpl implements PulsarClient {
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) {
@@ -526,7 +528,7 @@ public class PulsarClientImpl implements PulsarClient {
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);
