Skip to content

fix: add missing input validations and correct error messages in ConsumerSetting and ProducerSetting#1

Open
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1775812633-fix-validation-errors
Open

fix: add missing input validations and correct error messages in ConsumerSetting and ProducerSetting#1
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1775812633-fix-validation-errors

Conversation

@devin-ai-integration
Copy link
Copy Markdown

Summary

Fixes incorrect error messages and adds missing input validations in ConsumerSetting and ProducerSetting.

Error message fixes (both files):

  • Removed double space typo in all assertion messages ("of consumer""of consumer", "of producer""of producer")
  • Added trailing period to ConsumerSetting messages for consistency with ProducerSetting

ProducerSetting — nodeId validation fix:

  • Changed nodeId < 16383 to nodeId >= 0 && nodeId <= 16383. The previous check incorrectly rejected nodeId = 16383, despite the Javadoc stating max is 16383, the default value being 16383, and MsgId.toLong() accepting nodeId == 0x3fff (16383).
  • Added lower-bound check (>= 0) since negative node IDs are invalid.

New validations:

  • ConsumerSetting: pollSize > 0, consumerNum > 0, pollInterval >= 0 (all skip validation when null, since defaults are applied afterward)
  • ProducerSetting: reserveDays >= 0

Review & Testing Checklist for Human

  • Verify the nodeId <= 16383 boundary is correct — confirm in MsgId.toLong() that nodeId == 16383 is indeed valid (nodeId > 0x3fff is the rejection there, so 16383 should pass). This is a behavioral change: previously, explicitly setting nodeId=16383 would throw.
  • Confirm reserveDays has no legitimate negative use case — it's a primitive int defaulting to 0; the new check rejects negative values.
  • Spot-check that Spring property binding doesn't set pollSize/consumerNum to 0 in normal config flows — the new validations reject non-positive values when explicitly set but allow null (for default assignment).

Notes

  • No unit tests exist in this repo, so these changes are verified only by successful compilation.
  • Validations are placed before default assignments in afterProperties(), so null values pass through (guarded by == null || checks) and get their defaults on subsequent lines.

Link to Devin session: https://app.devin.ai/sessions/9a2daf0812e049298c54bd4ea18bb1d8
Requested by: @kenlin8827

…umerSetting 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 <kenlin8827@gmail.com>
@devin-ai-integration
Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant