CAMEL-24280: camel-aws2-mq - throw when pojoRequest=true and the body is the wrong type - #25184
Conversation
… is the wrong type Child of CAMEL-24261. MQ2Producer's listBrokers, createBroker, deleteBroker, rebootBroker, updateBroker and describeBroker branches only acted when the body was the matching request type under pojoRequest=true; any other body silently fell through with no AWS call and no error. Add the missing else that throws IllegalArgumentException naming the required type, consistent with CAMEL-23462. Six tests send a wrong-typed body to pojoRequest=true routes and assert the message; each was verified to fail (silent no-op) before the fix. The shared 4.22 upgrade-guide entry was added with CAMEL-24263. Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Andrea Cosentino <ancosen@gmail.com>
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🐫 Apache Camel Committers, please review the following items:
|
|
🧪 CI tested the following changed modules:
🔬 Scalpel shadow comparison — Scalpel: 9 tested, 29 compile-only — current: 9 all testedMaveniverse Scalpel detected 38 affected modules (current approach: 9).
|
gnodet
left a comment
There was a problem hiding this comment.
Clean, well-scoped PR that adds missing else branches in six MQ2Producer POJO-mode operations to throw IllegalArgumentException when the body is the wrong type, exactly matching the pattern established by sibling PRs (CAMEL-24277/MSK, CAMEL-24263/STS, CAMEL-24264/Translate). CI is green, tests are correct, and project conventions are followed.
Key observations:
- Implementation is consistent with the established pattern from sibling PRs in the CAMEL-24261 family.
- Tests correctly use AssertJ
assertThatThrownBy(per project conventions), assert bothhasRootCauseInstanceOf(IllegalArgumentException.class)and the exact message, and use package-private visibility. - All six operations are covered: listBrokers, createBroker, deleteBroker, rebootBroker, updateBroker, describeBroker.
Minor pre-existing note: the log message in describeBroker's POJO branch (line ~360) says "Reboot Broker command" instead of "Describe Broker command" — a copy-paste issue from before this PR, worth fixing in a follow-up.
This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.
Claude Code on behalf of Guillaume Nodet
Child of CAMEL-24261 (completing CAMEL-23462 across the AWS2 producers).
Problem
With
pojoRequest=true,MQ2Producer'slistBrokers,createBroker,deleteBroker,rebootBroker,updateBrokeranddescribeBrokerbranches onlyacted when the body was the matching request type; any other body fell through
the
instanceofwith noelse, so no AWS call was made, no response was set,and the original body was returned with no error.
Fix
Each branch now throws
IllegalArgumentExceptionnaming the required requesttype, e.g.:
Tests
Six tests in
MQProducerTestsend a wrong-typed body topojoRequest=trueroutes (reusing the module's
AmazonMQClientMock) and assert the message. Eachwas verified to fail (silent no-op) before the fix —
rebootBroker, for example,reports "Expecting code to raise a throwable" on
main. Class 15/15 green.Hermetic unit tests against the in-JVM mock (run region-free) — no localstack or
real AWS.
Docs / backport
The shared 4.22 upgrade-guide entry was added with CAMEL-24263. Main only, matching
the CAMEL-23462 precedent (behaviour change, shipped in a minor, not backported).
Claude Code on behalf of oscerd