Skip to content

[ISSUE #10774] Reject empty producer message lists - #10775

Open
Aias00 wants to merge 1 commit into
apache:developfrom
Aias00:fix/proxy-producer-empty-message-list
Open

[ISSUE #10774] Reject empty producer message lists#10775
Aias00 wants to merge 1 commit into
apache:developfrom
Aias00:fix/proxy-producer-empty-message-list

Conversation

@Aias00

@Aias00 Aias00 commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

What changed

  • Reject null or empty producer message lists before building the send context.
  • Add regression coverage for both empty and null message list inputs.

Fixes #10774.

Verification

mvn -pl proxy -Dtest=ProducerProcessorTest test

Result: BUILD SUCCESS. ProducerProcessorTest ran 8 tests with 0 failures, errors, or skips. Checkstyle and SpotBugs also passed in the Maven run.

Copilot AI review requested due to automatic review settings August 3, 2026 06:48

Copilot 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.

Pull request overview

This PR adds early validation in the proxy producer send path to reject null/empty message lists (avoiding raw NullPointerException / IndexOutOfBoundsException) and adds regression tests to ensure the failure is surfaced as a controlled ProxyException.

Changes:

  • Add a null/empty guard at the start of ProducerProcessor#sendMessage.
  • Add regression tests covering both Collections.emptyList() and null message list inputs.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
proxy/src/main/java/org/apache/rocketmq/proxy/processor/ProducerProcessor.java Adds an early guard to reject null/empty messageList before accessing messageList.get(0).
proxy/src/test/java/org/apache/rocketmq/proxy/processor/ProducerProcessorTest.java Adds tests asserting the returned future completes exceptionally for empty/null message lists.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +75 to +77
if (messageList == null || messageList.isEmpty()) {
throw new ProxyException(ProxyExceptionCode.FORBIDDEN, "message list is empty");
}
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 48.23%. Comparing base (eddb235) to head (37d8991).

Additional details and impacted files
@@              Coverage Diff              @@
##             develop   #10775      +/-   ##
=============================================
- Coverage      48.24%   48.23%   -0.01%     
+ Complexity     13496    13488       -8     
=============================================
  Files           1380     1380              
  Lines         101104   101106       +2     
  Branches       13107    13108       +1     
=============================================
- Hits           48773    48767       -6     
- Misses         46350    46352       +2     
- Partials        5981     5987       +6     

☔ 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.

@RockteMQ-AI RockteMQ-AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review by github-manager-bot

Summary

Adds null/empty guard for messageList in ProducerActivityManagerImpl.sendMessage() before accessing messageList.get(0), throwing ProxyException with FORBIDDEN instead of risking IndexOutOfBoundsException.

Findings

  • [Info] The fix is correct and minimal. Throwing ProxyException with FORBIDDEN is appropriate since sending zero messages is a client error.
  • [Info] Test coverage covers both null and empty cases, verifying the correct exception code and message.

Suggestions

  • Consider whether other entry points in ProducerActivityManagerImpl that access list elements by index (e.g., sendMessage variants with List<MessageView>) have similar guards. Consistency across the API surface would reduce future NPE/IOOBE risk.

LGTM.


Automated review by github-manager-bot

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] Proxy ProducerProcessor throws IndexOutOfBoundsException for empty send message list

4 participants