Skip to content

Check store offset reference is less than 256-byte long #629

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/main/java/com/rabbitmq/stream/impl/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ public class Client implements AutoCloseable {
private static final Charset CHARSET = StandardCharsets.UTF_8;
public static final int DEFAULT_PORT = 5552;
public static final int DEFAULT_TLS_PORT = 5551;
static final int MAX_REFERENCE_SIZE = 256;
static final OutboundEntityWriteCallback OUTBOUND_MESSAGE_WRITE_CALLBACK =
new OutboundMessageWriteCallback();
static final OutboundEntityWriteCallback OUTBOUND_MESSAGE_BATCH_WRITE_CALLBACK =
Expand Down Expand Up @@ -892,7 +893,7 @@ public Response declarePublisher(byte publisherId, String publisherReference, St
(publisherReference == null || publisherReference.isEmpty()
? 0
: publisherReference.length());
if (publisherReferenceSize >= 256) {
if (publisherReferenceSize >= MAX_REFERENCE_SIZE) {
throw new IllegalArgumentException(
"If specified, publisher reference must less than 256 characters");
}
Expand Down Expand Up @@ -1290,7 +1291,7 @@ public Response subscribe(
}

public void storeOffset(String reference, String stream, long offset) {
if (reference == null || reference.isEmpty() || reference.length() > 256) {
if (reference == null || reference.isEmpty() || reference.length() >= MAX_REFERENCE_SIZE) {
throw new IllegalArgumentException(
"Reference must a non-empty string of less than 256 characters");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

class StreamConsumerBuilder implements ConsumerBuilder {

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