Skip to content

Commit 8dd487a

Browse files
authored
Merge pull request #629 from rabbitmq/store-offset-reference-less-than-256-characters
Check store offset reference is less than 256-byte long
2 parents 58e88f3 + 195e9cc commit 8dd487a

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/main/java/com/rabbitmq/stream/impl/Client.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ public class Client implements AutoCloseable {
128128
private static final Charset CHARSET = StandardCharsets.UTF_8;
129129
public static final int DEFAULT_PORT = 5552;
130130
public static final int DEFAULT_TLS_PORT = 5551;
131+
static final int MAX_REFERENCE_SIZE = 256;
131132
static final OutboundEntityWriteCallback OUTBOUND_MESSAGE_WRITE_CALLBACK =
132133
new OutboundMessageWriteCallback();
133134
static final OutboundEntityWriteCallback OUTBOUND_MESSAGE_BATCH_WRITE_CALLBACK =
@@ -892,7 +893,7 @@ public Response declarePublisher(byte publisherId, String publisherReference, St
892893
(publisherReference == null || publisherReference.isEmpty()
893894
? 0
894895
: publisherReference.length());
895-
if (publisherReferenceSize >= 256) {
896+
if (publisherReferenceSize >= MAX_REFERENCE_SIZE) {
896897
throw new IllegalArgumentException(
897898
"If specified, publisher reference must less than 256 characters");
898899
}
@@ -1290,7 +1291,7 @@ public Response subscribe(
12901291
}
12911292

12921293
public void storeOffset(String reference, String stream, long offset) {
1293-
if (reference == null || reference.isEmpty() || reference.length() > 256) {
1294+
if (reference == null || reference.isEmpty() || reference.length() >= MAX_REFERENCE_SIZE) {
12941295
throw new IllegalArgumentException(
12951296
"Reference must a non-empty string of less than 256 characters");
12961297
}

src/main/java/com/rabbitmq/stream/impl/StreamConsumerBuilder.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
class StreamConsumerBuilder implements ConsumerBuilder {
3232

33-
private static final int NAME_MAX_SIZE = 256; // server-side limitation
33+
private static final int NAME_MAX_SIZE = Client.MAX_REFERENCE_SIZE; // server-side limitation
3434
private static final TrackingConfiguration DISABLED_TRACKING_CONFIGURATION =
3535
new TrackingConfiguration(false, false, -1, Duration.ZERO, Duration.ZERO);
3636
private final StreamEnvironment environment;

0 commit comments

Comments
 (0)