diff --git a/src/main/java/io/nats/client/api/ConsumerSource.java b/src/main/java/io/nats/client/api/ConsumerSource.java index 65a0c7f75..5ff754f02 100644 --- a/src/main/java/io/nats/client/api/ConsumerSource.java +++ b/src/main/java/io/nats/client/api/ConsumerSource.java @@ -48,16 +48,16 @@ static ConsumerSource optionalInstance(JsonValue vConsumerSource) { * @param name the consumer name * @param deliverSubject the deliver subject */ - public ConsumerSource(String name, String deliverSubject) { - this.name = name; - this.deliverSubject = deliverSubject; + public ConsumerSource(@NonNull String name, @NonNull String deliverSubject) { + this.name = validateConsumerName(name, true); + this.deliverSubject = validateSubject(deliverSubject, true); } /** * Construct a ConsumerSource configuration copying the information from another ConsumerSource * @param consumerSource the source configuration */ - public ConsumerSource(ConsumerSource consumerSource) { + public ConsumerSource(@NonNull ConsumerSource consumerSource) { this.name = consumerSource.name; this.deliverSubject = consumerSource.deliverSubject; } @@ -157,8 +157,6 @@ public Builder deliverSubject(String deliverSubject) { * @return the ConsumerSource object */ public ConsumerSource build() { - validateConsumerName(name, true); - validateSubject(deliverSubject, true); return new ConsumerSource(name, deliverSubject); } }