diff --git a/src/main/java/io/nats/client/api/OrderedConsumerConfiguration.java b/src/main/java/io/nats/client/api/OrderedConsumerConfiguration.java index f51c1b729..a5ee391e6 100644 --- a/src/main/java/io/nats/client/api/OrderedConsumerConfiguration.java +++ b/src/main/java/io/nats/client/api/OrderedConsumerConfiguration.java @@ -25,7 +25,7 @@ import static io.nats.client.support.JsonUtils.beginJson; import static io.nats.client.support.JsonUtils.endJson; import static io.nats.client.support.JsonValueUtils.*; -import static io.nats.client.support.NatsJetStreamConstants.DEFAULT_FILTER_SUBJECT; +import static io.nats.client.support.NatsConstants.GREATER_THAN; import static io.nats.client.support.Validator.emptyAsNull; public class OrderedConsumerConfiguration implements JsonSerializable { @@ -45,7 +45,7 @@ public class OrderedConsumerConfiguration implements JsonSerializable { public OrderedConsumerConfiguration() { startSequence = ConsumerConfiguration.LONG_UNSET; filterSubjects = new ArrayList<>(); - filterSubjects.add(DEFAULT_FILTER_SUBJECT); + filterSubjects.add(GREATER_THAN); } public OrderedConsumerConfiguration(String json) throws JsonParseException { @@ -118,7 +118,7 @@ public OrderedConsumerConfiguration filterSubjects(List filterSubjects) } } if (this.filterSubjects.isEmpty()) { - this.filterSubjects.add(DEFAULT_FILTER_SUBJECT); + this.filterSubjects.add(GREATER_THAN); } return this; } diff --git a/src/main/java/io/nats/client/api/StreamInfoOptions.java b/src/main/java/io/nats/client/api/StreamInfoOptions.java index 1df84ea88..a3aa9b60a 100644 --- a/src/main/java/io/nats/client/api/StreamInfoOptions.java +++ b/src/main/java/io/nats/client/api/StreamInfoOptions.java @@ -18,6 +18,7 @@ import static io.nats.client.support.ApiConstants.DELETED_DETAILS; import static io.nats.client.support.ApiConstants.SUBJECTS_FILTER; import static io.nats.client.support.JsonUtils.*; +import static io.nats.client.support.NatsConstants.GREATER_THAN; import static io.nats.client.support.Validator.emptyAsNull; /** @@ -110,7 +111,7 @@ public Builder filterSubjects(String subjectsFilter) { * @return the builder */ public Builder allSubjects() { - this.subjectsFilter = ">"; + this.subjectsFilter = GREATER_THAN; return this; } diff --git a/src/main/java/io/nats/client/impl/NatsJetStreamImpl.java b/src/main/java/io/nats/client/impl/NatsJetStreamImpl.java index ad8eea3da..0332a2177 100644 --- a/src/main/java/io/nats/client/impl/NatsJetStreamImpl.java +++ b/src/main/java/io/nats/client/impl/NatsJetStreamImpl.java @@ -25,7 +25,7 @@ import java.util.List; import java.util.concurrent.ConcurrentHashMap; -import static io.nats.client.support.NatsConstants.GT; +import static io.nats.client.support.NatsConstants.GREATER_THAN; import static io.nats.client.support.NatsJetStreamClientError.JsConsumerCreate290NotAvailable; import static io.nats.client.support.NatsJetStreamClientError.JsMultipleFilterSubjects210NotAvailable; import static io.nats.client.support.NatsRequestCompletableFuture.CancelAction; @@ -104,7 +104,7 @@ ConsumerInfo _createConsumer(String streamName, ConsumerConfiguration config, Co consumerName = durable == null ? generateConsumerName() : durable; } String fs = config.getFilterSubject(); // we've already determined not multiple so this gives us 1 or null - if (fs == null || fs.equals(GT)) { + if (fs == null || fs.equals(GREATER_THAN)) { subj = String.format(JSAPI_CONSUMER_CREATE_V290, streamName, consumerName); } else { diff --git a/src/main/java/io/nats/client/impl/NatsKeyValue.java b/src/main/java/io/nats/client/impl/NatsKeyValue.java index 895e21391..f3eaaf452 100644 --- a/src/main/java/io/nats/client/impl/NatsKeyValue.java +++ b/src/main/java/io/nats/client/impl/NatsKeyValue.java @@ -30,7 +30,9 @@ import java.util.concurrent.LinkedBlockingQueue; import static io.nats.client.support.NatsConstants.DOT; -import static io.nats.client.support.NatsJetStreamConstants.*; +import static io.nats.client.support.NatsConstants.GREATER_THAN; +import static io.nats.client.support.NatsJetStreamConstants.EXPECTED_LAST_SUB_SEQ_HDR; +import static io.nats.client.support.NatsJetStreamConstants.JS_WRONG_LAST_SEQUENCE; import static io.nats.client.support.NatsKeyValueUtil.*; import static io.nats.client.support.Validator.*; @@ -266,12 +268,12 @@ public NatsKeyValueWatchSubscription watch(List keys, KeyValueWatcher wa @Override public NatsKeyValueWatchSubscription watchAll(KeyValueWatcher watcher, KeyValueWatchOption... watchOptions) throws IOException, JetStreamApiException, InterruptedException { - return new NatsKeyValueWatchSubscription(this, Collections.singletonList(">"), watcher, -1, watchOptions); + return new NatsKeyValueWatchSubscription(this, Collections.singletonList(GREATER_THAN), watcher, -1, watchOptions); } @Override public NatsKeyValueWatchSubscription watchAll(KeyValueWatcher watcher, long fromRevision, KeyValueWatchOption... watchOptions) throws IOException, JetStreamApiException, InterruptedException { - return new NatsKeyValueWatchSubscription(this, Collections.singletonList(">"), watcher, fromRevision, watchOptions); + return new NatsKeyValueWatchSubscription(this, Collections.singletonList(GREATER_THAN), watcher, fromRevision, watchOptions); } /** @@ -279,7 +281,7 @@ public NatsKeyValueWatchSubscription watchAll(KeyValueWatcher watcher, long from */ @Override public List keys() throws IOException, JetStreamApiException, InterruptedException { - return _keys(Collections.singletonList(readSubject(DEFAULT_FILTER_SUBJECT))); + return _keys(Collections.singletonList(readSubject(GREATER_THAN))); } @Override @@ -312,7 +314,7 @@ private List _keys(List readSubjectFilters) throws IOException, */ @Override public LinkedBlockingQueue consumeKeys() { - return _consumeKeys(Collections.singletonList(readSubject(DEFAULT_FILTER_SUBJECT))); + return _consumeKeys(Collections.singletonList(readSubject(GREATER_THAN))); } @Override diff --git a/src/main/java/io/nats/client/impl/NatsObjectStore.java b/src/main/java/io/nats/client/impl/NatsObjectStore.java index bf89c53c8..87952ec54 100644 --- a/src/main/java/io/nats/client/impl/NatsObjectStore.java +++ b/src/main/java/io/nats/client/impl/NatsObjectStore.java @@ -27,6 +27,7 @@ import java.util.Arrays; import java.util.List; +import static io.nats.client.support.NatsConstants.GREATER_THAN; import static io.nats.client.support.NatsJetStreamClientError.*; import static io.nats.client.support.NatsObjectStoreUtil.*; @@ -73,7 +74,7 @@ String rawMetaSubject(String name) { } String rawAllMetaSubject() { - return rawMetaPrefix + ">"; + return rawMetaPrefix + GREATER_THAN; } String pubSubMetaSubject(String name) { diff --git a/src/main/java/io/nats/client/support/NatsConstants.java b/src/main/java/io/nats/client/support/NatsConstants.java index c00882253..7ab82331b 100644 --- a/src/main/java/io/nats/client/support/NatsConstants.java +++ b/src/main/java/io/nats/client/support/NatsConstants.java @@ -38,7 +38,7 @@ public interface NatsConstants { String EMPTY = ""; String CRLF = "\r\n"; String DOT = "."; - String GT = ">"; + String GREATER_THAN = ">"; String STAR = "*"; byte TAB = '\t'; diff --git a/src/main/java/io/nats/client/support/NatsJetStreamConstants.java b/src/main/java/io/nats/client/support/NatsJetStreamConstants.java index ee6c3645d..45aed12b2 100644 --- a/src/main/java/io/nats/client/support/NatsJetStreamConstants.java +++ b/src/main/java/io/nats/client/support/NatsJetStreamConstants.java @@ -108,6 +108,4 @@ public interface NatsJetStreamConstants { int JS_CONSUMER_NOT_FOUND_ERR = 10014; int JS_NO_MESSAGE_FOUND_ERR = 10037; int JS_WRONG_LAST_SEQUENCE = 10071; - - String DEFAULT_FILTER_SUBJECT = ">"; } diff --git a/src/main/java/io/nats/service/Group.java b/src/main/java/io/nats/service/Group.java index d6da0a8f7..e69e99c11 100644 --- a/src/main/java/io/nats/service/Group.java +++ b/src/main/java/io/nats/service/Group.java @@ -18,6 +18,7 @@ import java.util.Objects; import static io.nats.client.support.NatsConstants.DOT; +import static io.nats.client.support.NatsConstants.GREATER_THAN; import static io.nats.client.support.Validator.emptyAsNull; /** @@ -38,7 +39,7 @@ public Group(String name) { throw new IllegalArgumentException("Group name cannot be null or empty."); } - if (name.contains(">")) { + if (name.contains(GREATER_THAN)) { throw new IllegalArgumentException("Group name cannot contain '>'."); }