Claus Ibsen created CAMEL-26032:
-----------------------------------

             Summary: camel-aws2-ec2 - no operation fails with a 
NullPointerException, the instance type of the docs fails, and a text instance 
ids header is dropped
                 Key: CAMEL-26032
                 URL: https://issues.apache.org/jira/browse/CAMEL-26032
             Project: Camel
          Issue Type: Bug
          Components: camel-aws2
    Affects Versions: 4.18.0, 4.22.0, 4.23.0
            Reporter: Claus Ibsen
             Fix For: 4.24.0


Found while adding the catalog body types of aws2-ec2 (CAMEL-24961).

h4. 1. No operation fails with a NullPointerException

The operation is required and has no default. Without the operation option and 
the {{CamelAwsEC2Operation}} header, the producer fails with 
{{NullPointerException: Cannot invoke "...AWS2EC2Operations.ordinal()" because 
the return value of "...AWS2EC2Producer.determineOperation(...)" is null}} 
({{AWS2EC2Producer}}, main 07d2e7a987bc, line 83). Checked on 4.24.0-SNAPSHOT 
with {{camel run}} against the AWS emulator of {{camel infra run aws}}.

*Proposed change*: fail with a message that says the operation is missing, as 
aws2-kms and aws2-iam do.

h4. 2. The instance type of the docs fails

The XML and YAML examples of the docs set {{CamelAwsEC2InstanceType}} to 
{{t2.micro}}. The header is converted to the {{InstanceType}} enum of the AWS 
SDK ({{AWS2EC2Producer}}, line 177), and {{t2.micro}} is not the name of a 
constant, so createAndRunInstances fails with a {{TypeConversionException}}; 
{{T2_MICRO}} works. Checked on 4.24.0-SNAPSHOT with {{camel run}} against the 
AWS emulator of {{camel infra run aws}}.

*Proposed change*: take the AWS value ({{InstanceType.fromValue}}) as well as 
the constant name, or fix the examples.

h4. 3. A text CamelAwsEC2InstancesIds header is dropped

The ids must be a Collection. A String, such as {{i-1}}, converts to null, as 
Camel has no converter from text to a Collection, but the check before it 
passes on the header. So startInstances, stopInstances and the other operations 
send a request with no ids, and describeInstances describes all instances. 
Checked on 4.24.0-SNAPSHOT with {{camel run}} against the AWS emulator of 
{{camel infra run aws}}: stopInstances with the header {{i-1}} stopped nothing 
({{StoppingInstances=[]}}) and raised no error.

*Proposed change*: take a String of ids separated by commas, or fail when the 
header is not a Collection.

h4. Also read in the code, not run

* {{EC2ComponentIT}} and {{EC2ProducerTest}} wrap {{template.send}} in 
{{assertDoesNotThrow}}, which cannot fail: send does not throw for a failed 
exchange.

_Claude Code on behalf of davsclaus_



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to