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 9a41683b8870c6888a15e7910788e11a659c24ba Author: Andrea Cosentino <anco...@gmail.com> AuthorDate: Tue Mar 30 09:10:54 2021 +0200 Camel-AWS2-Lambda: Producer operations refactoring - getFunction --- .../component/aws2/lambda/Lambda2Producer.java | 37 +++++++++------------- 1 file changed, 15 insertions(+), 22 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 a291a2a..04b749a 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 @@ -152,31 +152,24 @@ public class Lambda2Producer extends DefaultProducer { } private void getFunction(LambdaClient lambdaClient, Exchange exchange) throws InvalidPayloadException { + GetFunctionRequest request = null; + GetFunctionResponse result; if (getConfiguration().isPojoRequest()) { - Object payload = exchange.getIn().getMandatoryBody(); - if (payload instanceof GetFunctionRequest) { - GetFunctionResponse result; - try { - result = lambdaClient.getFunction((GetFunctionRequest) payload); - } catch (AwsServiceException ase) { - LOG.trace("getFunction command returned the error code {}", ase.awsErrorDetails().errorCode()); - throw ase; - } - Message message = getMessageForResponse(exchange); - message.setBody(result); - } + request = exchange.getIn().getMandatoryBody(GetFunctionRequest.class); } else { - GetFunctionResponse result; - try { - result = lambdaClient - .getFunction(GetFunctionRequest.builder().functionName(getEndpoint().getFunction()).build()); - } catch (AwsServiceException ase) { - LOG.trace("getFunction command returned the error code {}", ase.awsErrorDetails().errorCode()); - throw ase; - } - Message message = getMessageForResponse(exchange); - message.setBody(result); + GetFunctionRequest.Builder builder = GetFunctionRequest.builder(); + builder.functionName(getEndpoint().getFunction()); + request = builder.build(); + } + try { + result = lambdaClient + .getFunction(request); + } catch (AwsServiceException ase) { + LOG.trace("getFunction command returned the error code {}", ase.awsErrorDetails().errorCode()); + throw ase; } + Message message = getMessageForResponse(exchange); + message.setBody(result); } private void deleteFunction(LambdaClient lambdaClient, Exchange exchange) throws InvalidPayloadException {