Skip to content

fix: validate message batch input#10459

Open
gaoxiaolei-s59 wants to merge 1 commit into
apache:developfrom
gaoxiaolei-s59:codex/fix-messagebatch-input-validation
Open

fix: validate message batch input#10459
gaoxiaolei-s59 wants to merge 1 commit into
apache:developfrom
gaoxiaolei-s59:codex/fix-messagebatch-input-validation

Conversation

@gaoxiaolei-s59

Copy link
Copy Markdown
Contributor

What is the purpose of the change

Fixes #10458

MessageBatch.generateFromList used Java assert statements to validate null and empty input. That made invalid input behavior depend on assertion settings, producing AssertionError when assertions are enabled or later NullPointerException when they are disabled.

This PR replaces the assertions with explicit IllegalArgumentException validation.

Brief changelog

  • Validate null and empty message collections explicitly in MessageBatch.generateFromList
  • Add unit coverage for null and empty message collection inputs

Verifying this change

  • mvn -pl common -Dtest=MessageBatchTest -Dspotbugs.skip=true test

Note

A full mvn -pl common -Dtest=MessageBatchTest test run failed before surefire in this local environment because SpotBugs hit java.lang.UnsupportedOperationException: The Security Manager is deprecated and will be removed in a future release on the current JDK. The targeted test command above was used to verify the change.

@gaoxiaolei-s59 gaoxiaolei-s59 marked this pull request as ready for review June 10, 2026 07:34

@oss-sentinel-ai oss-sentinel-ai left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: Approved ✅

PR: #10459 — fix: validate message batch input
Type: Bug fix (2 files, +13/-2)

Assessment

Clean implementation that fixes #10458 by replacing assert statements with explicit validation.

Changes

  • MessageBatch.java: Replaced assert messages != null and assert messages.size() > 0 with explicit IllegalArgumentException validation
  • MessageBatchTest.java: Added two test cases covering null and empty message collections

Verdict

✅ Minimal, well-tested fix that ensures consistent behavior regardless of JVM assertion settings.


🤖 Automated review by oss-sentinel-ai

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 47.99%. Comparing base (2319d2f) to head (b79e957).
⚠️ Report is 2 commits behind head on develop.

Additional details and impacted files
@@              Coverage Diff              @@
##             develop   #10459      +/-   ##
=============================================
- Coverage      48.11%   47.99%   -0.13%     
+ Complexity     13329    13291      -38     
=============================================
  Files           1377     1377              
  Lines         100632   100631       -1     
  Branches       12995    12994       -1     
=============================================
- Hits           48422    48293     -129     
- Misses         46289    46403     +114     
- Partials        5921     5935      +14     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

[Bug] MessageBatch.generateFromList should reject null or empty input explicitly

4 participants