Skip to content

Commit 613c289

Browse files
authored
GH-2552: Fix Builder Argument Types maxLength etc
Resolves #2552 Variables map to Erlang ints which are 8 bytes, so need to be long in Java.
1 parent 1b38f94 commit 613c289

File tree

6 files changed

+28
-13
lines changed

6 files changed

+28
-13
lines changed

spring-amqp/src/main/java/org/springframework/amqp/core/QueueBuilder.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2022 the original author or authors.
2+
* Copyright 2016-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -150,12 +150,26 @@ public QueueBuilder expires(int expires) {
150150
* @param count the number of (ready) messages allowed.
151151
* @return the builder.
152152
* @since 2.2
153+
* @deprecated in favor of {@link #maxLength(long)}.
153154
* @see #overflow(Overflow)
154155
*/
156+
@Deprecated
155157
public QueueBuilder maxLength(int count) {
156158
return withArgument("x-max-length", count);
157159
}
158160

161+
/**
162+
* Set the number of (ready) messages allowed in the queue before it starts to drop
163+
* them.
164+
* @param count the number of (ready) messages allowed.
165+
* @return the builder.
166+
* @since 3.1
167+
* @see #overflow(Overflow)
168+
*/
169+
public QueueBuilder maxLength(long count) {
170+
return withArgument("x-max-length", count);
171+
}
172+
159173
/**
160174
* Set the total aggregate body size allowed in the queue before it starts to drop
161175
* them.

spring-rabbit-stream/src/main/java/org/springframework/rabbit/stream/config/SuperStreamBuilder.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
* Based on <a href="https://www.rabbitmq.com/streams.html">Streams documentation</a>
2929
*
3030
* @author Sergei Kurenchuk
31+
* @author Gary Russell
3132
* @since 3.1
3233
*/
3334
public class SuperStreamBuilder {
@@ -73,7 +74,7 @@ public SuperStreamBuilder maxAge(String maxAge) {
7374
* @param bytes the max total size in bytes
7475
* @return the builder
7576
*/
76-
public SuperStreamBuilder maxLength(int bytes) {
77+
public SuperStreamBuilder maxLength(long bytes) {
7778
return withArgument("max-length-bytes", bytes);
7879
}
7980

@@ -82,7 +83,7 @@ public SuperStreamBuilder maxLength(int bytes) {
8283
* @param bytes the max segments size in bytes
8384
* @return the builder
8485
*/
85-
public SuperStreamBuilder maxSegmentSize(int bytes) {
86+
public SuperStreamBuilder maxSegmentSize(long bytes) {
8687
return withArgument("x-stream-max-segment-size-bytes", bytes);
8788
}
8889

spring-rabbit-stream/src/test/java/org/springframework/rabbit/stream/config/SuperStreamConfigurationTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ void builderMustSetupArguments() {
8585
var finalPartitionsNumber = 4;
8686
var finalName = "test-name";
8787
var maxAge = "1D";
88-
var maxLength = 10_000_000;
89-
var maxSegmentsSize = 100_000;
88+
var maxLength = 10_000_000L;
89+
var maxSegmentsSize = 100_000L;
9090
var initialClusterSize = 5;
9191

9292
var testArgName = "test-key";

spring-rabbit/src/test/java/org/springframework/amqp/rabbit/core/FixedReplyQueueDeadLetterTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2022 the original author or authors.
2+
* Copyright 2014-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -265,7 +265,7 @@ public Queue allArgs1() {
265265
return QueueBuilder.nonDurable("all.args.1")
266266
.ttl(1000)
267267
.expires(200_000)
268-
.maxLength(42)
268+
.maxLength(42L)
269269
.maxLengthBytes(10_000)
270270
.overflow(Overflow.rejectPublish)
271271
.deadLetterExchange("reply.dlx")
@@ -282,7 +282,7 @@ public Queue allArgs2() {
282282
return QueueBuilder.nonDurable("all.args.2")
283283
.ttl(1000)
284284
.expires(200_000)
285-
.maxLength(42)
285+
.maxLength(42L)
286286
.maxLengthBytes(10_000)
287287
.overflow(Overflow.dropHead)
288288
.deadLetterExchange("reply.dlx")
@@ -298,7 +298,7 @@ public Queue allArgs3() {
298298
return QueueBuilder.nonDurable("all.args.3")
299299
.ttl(1000)
300300
.expires(200_000)
301-
.maxLength(42)
301+
.maxLength(42L)
302302
.maxLengthBytes(10_000)
303303
.overflow(Overflow.rejectPublish)
304304
.deadLetterExchange("reply.dlx")

spring-rabbit/src/test/java/org/springframework/amqp/rabbit/core/RabbitTemplatePublisherCallbacksIntegrationTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -833,7 +833,7 @@ public void testWithFuture() throws Exception {
833833
RabbitAdmin admin = new RabbitAdmin(this.connectionFactory);
834834
Queue queue = QueueBuilder.nonDurable()
835835
.autoDelete()
836-
.maxLength(1)
836+
.maxLength(1L)
837837
.overflow(Overflow.rejectPublish)
838838
.build();
839839
admin.declareQueue(queue);

spring-rabbit/src/test/java/org/springframework/amqp/rabbit/retry/RepublishMessageRecovererWithConfirmsIntegrationTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2018-2019 the original author or authors.
2+
* Copyright 2018-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -103,7 +103,7 @@ void testCorrelatedWithNack() {
103103
RabbitTemplate template = new RabbitTemplate(ccf);
104104
RabbitAdmin admin = new RabbitAdmin(ccf);
105105
Queue queue = QueueBuilder.durable(QUEUE + ".nack")
106-
.maxLength(1)
106+
.maxLength(1L)
107107
.overflow(Overflow.rejectPublish)
108108
.build();
109109
admin.declareQueue(queue);

0 commit comments

Comments
 (0)