CAMEL-24300: camel-aws2-ec2 - throw when pojoRequest=true and the body is the wrong type - #25215
Conversation
…y is the wrong type Child of CAMEL-24261. AWS2EC2Producer's nine operations (createAndRunInstances, startInstances, stopInstances, terminateInstances, rebootInstances, monitorInstances, unmonitorInstances, createTags, deleteTags) 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. A parameterized test covers all nine operations; 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>
gnodet
left a comment
There was a problem hiding this comment.
Clean, well-structured PR that correctly adds IllegalArgumentException for all 9 EC2 operations when pojoRequest=true and the body is the wrong type. Consistent with sibling PRs in the CAMEL-24261 series.
Key observations:
- All 9 operations with manual
if (payload instanceof ...)pattern correctly received theelsebranch - The two remaining operations (
describeInstances,describeInstancesStatus) use theexecuteOperationhelper which already throws on type mismatch — correctly excluded - Error message format is consistent with sibling PRs (CAMEL-24283/comprehend, CAMEL-24280/mq, CAMEL-24264/translate, etc.)
- Test uses AssertJ (
assertThatThrownBy) and is package-private — follows project conventions - Parameterized test comprehensively covers all operations
Minor nit (non-blocking): Per project conventions, when modifying an existing test file the public modifier could be removed from the EC2ProducerTest class declaration (public class → class). This is incremental cleanup, not a blocker.
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
|
🌟 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).
|
Child of CAMEL-24261 (completing CAMEL-23462 across the AWS2 producers).
Problem
With
pojoRequest=true,AWS2EC2Producer's nine operations only acted when thebody was the matching request type; any other body fell through the
instanceofwith no
else, so no AWS call was made, no response was set, and the originalbody was returned with no error.
Fix
Each branch now throws
IllegalArgumentExceptionnaming the required requesttype. The message names the operation the user configured — e.g.
createAndRunInstances(the enum/URI operation) rather than the internal methodname
createAndRunInstance.Tests
A
@ParameterizedTestcovers all nine operations, sending a wrong-typed body topojoRequest=trueroutes and asserting each message. Verified to fail (silentno-op) before the fix — with the
stopInstanceselse removed, exactly that casereports "Expecting code to raise a throwable". Class 20/20 green. Hermetic unit
tests, 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