diff --git a/spring-cloud-function-adapters/spring-cloud-function-adapter-aws/src/main/java/org/springframework/cloud/function/adapter/aws/SpringBootApiGatewayRequestHandler.java b/spring-cloud-function-adapters/spring-cloud-function-adapter-aws/src/main/java/org/springframework/cloud/function/adapter/aws/SpringBootApiGatewayRequestHandler.java index 07c86f328..a2bb3e4ff 100644 --- a/spring-cloud-function-adapters/spring-cloud-function-adapter-aws/src/main/java/org/springframework/cloud/function/adapter/aws/SpringBootApiGatewayRequestHandler.java +++ b/spring-cloud-function-adapters/spring-cloud-function-adapter-aws/src/main/java/org/springframework/cloud/function/adapter/aws/SpringBootApiGatewayRequestHandler.java @@ -35,7 +35,7 @@ import org.springframework.messaging.support.GenericMessage; /** * @author Dave Syer * @author Oleg Zhurakousky - * + * @author Semyon Fishman */ public class SpringBootApiGatewayRequestHandler extends SpringBootRequestHandler { @@ -128,10 +128,12 @@ public class SpringBootApiGatewayRequestHandler extends @Override public Object handleRequest(APIGatewayProxyRequestEvent event, Context context) { Object response = super.handleRequest(event, context); - if (returnsOutput()) + if (returnsOutput()) { return response; - else + } + else { return new APIGatewayProxyResponseEvent() .withStatusCode(HttpStatus.OK.value()); + } } } diff --git a/spring-cloud-function-adapters/spring-cloud-function-adapter-aws/src/main/java/org/springframework/cloud/function/adapter/aws/SpringFunctionInitializer.java b/spring-cloud-function-adapters/spring-cloud-function-adapter-aws/src/main/java/org/springframework/cloud/function/adapter/aws/SpringFunctionInitializer.java index 3e8ed3e2a..ba1cfa489 100644 --- a/spring-cloud-function-adapters/spring-cloud-function-adapter-aws/src/main/java/org/springframework/cloud/function/adapter/aws/SpringFunctionInitializer.java +++ b/spring-cloud-function-adapters/spring-cloud-function-adapter-aws/src/main/java/org/springframework/cloud/function/adapter/aws/SpringFunctionInitializer.java @@ -43,6 +43,7 @@ import org.springframework.util.ClassUtils; /** * @author Dave Syer + * @author Semyon Fishman */ public class SpringFunctionInitializer implements Closeable { @@ -127,7 +128,6 @@ public class SpringFunctionInitializer implements Closeable { } } - @SuppressWarnings("unchecked") protected void initialize() { if (!this.initialized.compareAndSet(false, true)) { return; @@ -147,17 +147,22 @@ public class SpringFunctionInitializer implements Closeable { private String resolveName(Class type) { String functionName = context.getEnvironment().getProperty("function.name"); - if (functionName != null) + if (functionName != null) { return functionName; - else if (type.isAssignableFrom(Function.class)) + } + else if (type.isAssignableFrom(Function.class)) { return "function"; - else if (type.isAssignableFrom(Consumer.class)) + } + else if (type.isAssignableFrom(Consumer.class)) { return "consumer"; - else if (type.isAssignableFrom(Supplier.class)) + } + else if (type.isAssignableFrom(Supplier.class)) { return "supplier"; + } throw new IllegalStateException("Unknown type " + type); } + @SuppressWarnings("unchecked") private void initFunctionConsumerOrSupplierFromContext() { String name = resolveName(Function.class); if (context.containsBean(name) && context.getBean(name) instanceof Function) { @@ -181,18 +186,21 @@ public class SpringFunctionInitializer implements Closeable { private void initFunctionConsumerOrSupplierFromCatalog() { String name = resolveName(Function.class); this.function = this.catalog.lookup(Function.class, name); - if (this.function != null) + if (this.function != null) { return; + } name = resolveName(Consumer.class); this.consumer = this.catalog.lookup(Consumer.class, name); - if (this.consumer != null) + if (this.consumer != null) { return; + } name = resolveName(Supplier.class); this.supplier = this.catalog.lookup(Supplier.class, name); - if (this.supplier != null) + if (this.supplier != null) { return; + } if (this.catalog.size() == 1) { Iterator names = this.catalog.getNames(Function.class).iterator(); @@ -231,14 +239,16 @@ public class SpringFunctionInitializer implements Closeable { } protected Object function() { - if (this.function != null) + if (this.function != null) { return this.function; - else if (this.consumer != null) + } + else if (this.consumer != null) { return this.consumer; - else if (this.supplier != null) + } + else if (this.supplier != null) { return this.supplier; - else - return null; + } + return null; } protected boolean acceptsInput() {