gnodet-bot commented on code in PR #28353:
URL: https://github.com/apache/camel/pull/28353#discussion_r4364396672


##########
components/camel-aws/camel-aws2-ec2/src/main/java/org/apache/camel/component/aws2/ec2/AWS2EC2Producer.java:
##########
@@ -670,6 +677,63 @@ public static Message getMessageForResponse(final Exchange 
exchange) {
         return exchange.getMessage();
     }
 
+    /**
+     * The instance type of the {@link AWS2EC2Constants#INSTANCE_TYPE} header: 
an {@link InstanceType}, its AWS value
+     * (such as t2.micro), or the name of the constant (such as T2_MICRO).
+     */
+    private InstanceType getInstanceType(Exchange exchange) {
+        Object value = 
exchange.getIn().getHeader(AWS2EC2Constants.INSTANCE_TYPE);
+        if (value instanceof InstanceType instanceType) {
+            return instanceType;
+        }
+        String text = 
exchange.getIn().getHeader(AWS2EC2Constants.INSTANCE_TYPE, String.class);
+        if (text != null) {
+            text = text.trim();
+            InstanceType instanceType = InstanceType.fromValue(text);
+            if (instanceType != null && instanceType != 
InstanceType.UNKNOWN_TO_SDK_VERSION) {
+                return instanceType;
+            }
+            for (InstanceType candidate : InstanceType.knownValues()) {
+                if (candidate.name().equals(text)) {
+                    return candidate;
+                }
+            }
+        }
+        throw new IllegalArgumentException(
+                "Unknown instance type " + value + " in the " + 
AWS2EC2Constants.INSTANCE_TYPE
+                                           + " header: expected an 
InstanceType, such as t2.micro or T2_MICRO");
+    }
+
+    /**
+     * The instance ids of the {@link AWS2EC2Constants#INSTANCES_IDS} header: 
a Collection of ids, or a String of ids
+     * separated by commas. Returns null when the header is not set.
+     */
+    private Collection<String> getInstanceIds(Exchange exchange) {
+        Object value = 
exchange.getIn().getHeader(AWS2EC2Constants.INSTANCES_IDS);
+        if (value == null) {
+            return null;
+        }
+        if (value instanceof Collection<?> collection) {
+            List<String> ids = new ArrayList<>(collection.size());
+            for (Object id : collection) {
+                ids.add(id != null ? id.toString() : null);

Review Comment:
   Test



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to