This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 26101d0a73aaf291d3270dcd94fd90cd4204c2b4
Author: Andrea Cosentino <anco...@gmail.com>
AuthorDate: Wed Mar 31 11:26:04 2021 +0200

    Camel-AWS2-Lambda: Producer operations refactoring - listAliases
---
 .../component/aws2/lambda/Lambda2Producer.java     | 27 ++++++++--------------
 1 file changed, 9 insertions(+), 18 deletions(-)

diff --git 
a/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Producer.java
 
b/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Producer.java
index e960a67..9d0aeaa 100644
--- 
a/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Producer.java
+++ 
b/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Producer.java
@@ -696,36 +696,27 @@ public class Lambda2Producer extends DefaultProducer {
     }
 
     private void listAliases(LambdaClient lambdaClient, Exchange exchange) 
throws InvalidPayloadException {
+       ListAliasesRequest request = null;
+       ListAliasesResponse result;
         if (getConfiguration().isPojoRequest()) {
-            Object payload = exchange.getIn().getMandatoryBody();
-            if (payload instanceof ListAliasesRequest) {
-                ListAliasesResponse result;
-                try {
-                    result = lambdaClient.listAliases((ListAliasesRequest) 
payload);
-                } catch (AwsServiceException ase) {
-                    LOG.trace("listAliases command returned the error code 
{}", ase.awsErrorDetails().errorCode());
-                    throw ase;
-                }
-                Message message = getMessageForResponse(exchange);
-                message.setBody(result);
-            }
+            request = 
exchange.getIn().getMandatoryBody(ListAliasesRequest.class);
         } else {
-            ListAliasesResponse result;
-            try {
-                ListAliasesRequest.Builder request = 
ListAliasesRequest.builder().functionName(getEndpoint().getFunction());
+                ListAliasesRequest.Builder builder = 
ListAliasesRequest.builder();
+                builder.functionName(getEndpoint().getFunction());
                 String version = 
exchange.getIn().getHeader(Lambda2Constants.FUNCTION_VERSION, String.class);
                 if (ObjectHelper.isEmpty(version)) {
                     throw new IllegalArgumentException("Function Version must 
be specified to list aliases for a function");
                 }
-                request.functionVersion(version);
-                result = lambdaClient.listAliases(request.build());
+                builder.functionVersion(version);
+        }
+        try {
+                result = lambdaClient.listAliases(request);
             } catch (AwsServiceException ase) {
                 LOG.trace("listAliases command returned the error code {}", 
ase.awsErrorDetails().errorCode());
                 throw ase;
             }
             Message message = getMessageForResponse(exchange);
             message.setBody(result);
-        }
     }
 
     private Lambda2Operations determineOperation(Exchange exchange) {

Reply via email to