From a3014234b3fe527ab94237fd59e9f2f856f12799 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Fri, 10 Apr 2026 09:18:28 +0000 Subject: [PATCH] fix: add missing input validations and correct error messages in ConsumerSetting and ProducerSetting ConsumerSetting.java: - Fix double space in error messages ('of consumer' -> 'of consumer') - Add missing trailing period to error messages for consistency - Add validation for pollSize (must be > 0) - Add validation for pollInterval (must be >= 0) - Add validation for consumerNum (must be > 0) ProducerSetting.java: - Fix double space in error messages ('of producer' -> 'of producer') - Fix off-by-one in nodeId validation (< 16383 -> <= 16383) to match the documented max value and the check in MsgId.toLong() - Add validation for nodeId being non-negative (>= 0) - Add validation for reserveDays (must be >= 0) Co-Authored-By: kenlin --- .../io/github/ithamal/queue/config/ConsumerSetting.java | 7 +++++-- .../io/github/ithamal/queue/config/ProducerSetting.java | 7 ++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/java/io/github/ithamal/queue/config/ConsumerSetting.java b/src/main/java/io/github/ithamal/queue/config/ConsumerSetting.java index 39b4ce9..ce45c50 100644 --- a/src/main/java/io/github/ithamal/queue/config/ConsumerSetting.java +++ b/src/main/java/io/github/ithamal/queue/config/ConsumerSetting.java @@ -37,8 +37,11 @@ public class ConsumerSetting { private String implClass; public void afterProperties() { - Assert.notNull(queue, "A property 'queue' of consumer setting isn't specified"); - Assert.notNull(implClass, "A property 'implClass' of consumer setting isn't specified"); + Assert.notNull(queue, "A property 'queue' of consumer setting isn't specified."); + Assert.notNull(implClass, "A property 'implClass' of consumer setting isn't specified."); + Assert.isTrue(pollSize == null || pollSize > 0, "A property 'pollSize' of consumer setting must be greater than 0."); + Assert.isTrue(pollInterval == null || pollInterval >= 0, "A property 'pollInterval' of consumer setting must not be negative."); + Assert.isTrue(consumerNum == null || consumerNum > 0, "A property 'consumerNum' of consumer setting must be greater than 0."); name = name != null ? name : queue; groupName = groupName != null ? groupName : "default"; prefix = prefix != null ? prefix : "queue:"; diff --git a/src/main/java/io/github/ithamal/queue/config/ProducerSetting.java b/src/main/java/io/github/ithamal/queue/config/ProducerSetting.java index c7ca37e..276fd01 100644 --- a/src/main/java/io/github/ithamal/queue/config/ProducerSetting.java +++ b/src/main/java/io/github/ithamal/queue/config/ProducerSetting.java @@ -31,9 +31,10 @@ public class ProducerSetting { private Integer nodeId; public void afterProperties() { - Assert.notNull(queue, "A property 'queue' of producer setting isn't specified."); - Assert.notNull(implClass, "A property 'implClass' of producer setting isn't specified."); - Assert.isTrue(nodeId == null || nodeId < 16383, "A property 'nodeId' of producer setting must less than 16383."); + Assert.notNull(queue, "A property 'queue' of producer setting isn't specified."); + Assert.notNull(implClass, "A property 'implClass' of producer setting isn't specified."); + Assert.isTrue(nodeId == null || (nodeId >= 0 && nodeId <= 16383), "A property 'nodeId' of producer setting must be between 0 and 16383."); + Assert.isTrue(reserveDays >= 0, "A property 'reserveDays' of producer setting must not be negative."); name = name != null ? name : queue; prefix = prefix != null ? prefix : "queue:"; serializer = serializer != null ? serializer : "json";