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 e79a455f9dcc1467908b33f87dbfafc0a9913729 Author: Andrea Cosentino <[email protected]> AuthorDate: Tue Mar 30 09:17:04 2021 +0200 Camel-AWS2-Lambda: Producer operations refactoring - deleteFunction --- .../component/aws2/lambda/Lambda2Producer.java | 23 ++++++++-------------- 1 file changed, 8 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 8f42fad..2b28ef5 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 @@ -173,31 +173,24 @@ public class Lambda2Producer extends DefaultProducer { } private void deleteFunction(LambdaClient lambdaClient, Exchange exchange) throws InvalidPayloadException { + DeleteFunctionRequest request = null; + DeleteFunctionResponse result; if (getConfiguration().isPojoRequest()) { - Object payload = exchange.getIn().getMandatoryBody(); - if (payload instanceof DeleteFunctionRequest) { - DeleteFunctionResponse result; - try { - result = lambdaClient.deleteFunction((DeleteFunctionRequest) payload); - } catch (AwsServiceException ase) { - LOG.trace("deleteFunction command returned the error code {}", ase.awsErrorDetails().errorCode()); - throw ase; - } - Message message = getMessageForResponse(exchange); - message.setBody(result); - } + request = exchange.getIn().getMandatoryBody(DeleteFunctionRequest.class); } else { - DeleteFunctionResponse result; + DeleteFunctionRequest.Builder builder = DeleteFunctionRequest.builder(); + builder.functionName(getEndpoint().getFunction()); + request = builder.build(); + } try { result = lambdaClient - .deleteFunction(DeleteFunctionRequest.builder().functionName(getEndpoint().getFunction()).build()); + .deleteFunction(request); } catch (AwsServiceException ase) { LOG.trace("deleteFunction command returned the error code {}", ase.awsErrorDetails().errorCode()); throw ase; } Message message = getMessageForResponse(exchange); message.setBody(result); - } } private void listFunctions(LambdaClient lambdaClient, Exchange exchange) throws InvalidPayloadException {
