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 010e3ea11473593102d5dcd5bc0759c4466f7142
Author: Andrea Cosentino <anco...@gmail.com>
AuthorDate: Tue Mar 30 09:22:42 2021 +0200

    Camel-AWS2-Lambda: Producer operations refactoring - listFunctions
---
 .../component/aws2/lambda/Lambda2Producer.java     | 22 +++++++---------------
 1 file changed, 7 insertions(+), 15 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 1c56c32..29f5ff4 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
@@ -194,30 +194,22 @@ public class Lambda2Producer extends DefaultProducer {
     }
 
     private void listFunctions(LambdaClient lambdaClient, Exchange exchange) 
throws InvalidPayloadException {
+       ListFunctionsRequest request = null;
+       ListFunctionsResponse result;
         if (getConfiguration().isPojoRequest()) {
-            Object payload = exchange.getIn().getMandatoryBody();
-            if (payload instanceof ListFunctionsRequest) {
-                ListFunctionsResponse result;
-                try {
-                    result = lambdaClient.listFunctions((ListFunctionsRequest) 
payload);
-                } catch (AwsServiceException ase) {
-                    LOG.trace("listFunctions command returned the error code 
{}", ase.awsErrorDetails().errorCode());
-                    throw ase;
-                }
-                Message message = getMessageForResponse(exchange);
-                message.setBody(result);
-            }
+            request = 
exchange.getIn().getMandatoryBody(ListFunctionsRequest.class);
         } else {
-            ListFunctionsResponse result;
+            ListFunctionsRequest.Builder builder = 
ListFunctionsRequest.builder();
+            request = builder.build();
+        }
             try {
-                result = lambdaClient.listFunctions();
+                result = lambdaClient.listFunctions(request);
             } catch (AwsServiceException ase) {
                 LOG.trace("listFunctions command returned the error code {}", 
ase.awsErrorDetails().errorCode());
                 throw ase;
             }
             Message message = getMessageForResponse(exchange);
             message.setBody(result);
-        }
     }
 
     private void invokeFunction(LambdaClient lambdaClient, Exchange exchange) 
throws InvalidPayloadException {

Reply via email to