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 8a714fc40f2bf08cd66b24f8af6de3f579af4fd0
Author: Andrea Cosentino <anco...@gmail.com>
AuthorDate: Wed Mar 31 08:29:47 2021 +0200

    Camel-AWS2-Lambda: Producer operations refactoring - listEventSourceMappings
---
 .../component/aws2/lambda/Lambda2Producer.java     | 25 +++++++---------------
 1 file changed, 8 insertions(+), 17 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 5caae82..4418a23 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
@@ -458,32 +458,23 @@ public class Lambda2Producer extends DefaultProducer {
     }
 
     private void listEventSourceMapping(LambdaClient lambdaClient, Exchange 
exchange) throws InvalidPayloadException {
+       ListEventSourceMappingsRequest request = null;
+       ListEventSourceMappingsResponse result;
         if (getConfiguration().isPojoRequest()) {
-            Object payload = exchange.getIn().getMandatoryBody();
-            if (payload instanceof ListEventSourceMappingsRequest) {
-                ListEventSourceMappingsResponse result;
-                try {
-                    result = 
lambdaClient.listEventSourceMappings((ListEventSourceMappingsRequest) payload);
-                } catch (AwsServiceException ase) {
-                    LOG.trace("listEventSourceMapping command returned the 
error code {}", ase.awsErrorDetails().errorCode());
-                    throw ase;
-                }
-                Message message = getMessageForResponse(exchange);
-                message.setBody(result);
-            }
+            request = 
exchange.getIn().getMandatoryBody(ListEventSourceMappingsRequest.class);
         } else {
-            ListEventSourceMappingsResponse result;
+                ListEventSourceMappingsRequest.Builder builder = 
ListEventSourceMappingsRequest.builder();
+                builder.functionName(getEndpoint().getFunction());
+                request = builder.build();
+        }
             try {
-                ListEventSourceMappingsRequest.Builder request
-                        = 
ListEventSourceMappingsRequest.builder().functionName(getEndpoint().getFunction());
-                result = lambdaClient.listEventSourceMappings(request.build());
+                result = lambdaClient.listEventSourceMappings(request);
             } catch (AwsServiceException ase) {
                 LOG.trace("listEventSourceMapping command returned the error 
code {}", ase.awsErrorDetails().errorCode());
                 throw ase;
             }
             Message message = getMessageForResponse(exchange);
             message.setBody(result);
-        }
     }
 
     private void listTags(LambdaClient lambdaClient, Exchange exchange) throws 
InvalidPayloadException {

Reply via email to