GH-743 Remove setting of HTTP 'export' properties for AWS Custom Runtime

Resolves #743
This commit is contained in:
Oleg Zhurakousky
2021-09-16 11:27:17 +02:00
parent 47e85d7cb2
commit 3b4b7aae5c
2 changed files with 15 additions and 24 deletions

View File

@@ -29,13 +29,7 @@ import java.util.concurrent.atomic.AtomicReference;
import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyRequestEvent;
import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyResponseEvent;
import com.amazonaws.services.lambda.runtime.events.APIGatewayV2HTTPEvent;
import com.amazonaws.services.lambda.runtime.events.APIGatewayV2HTTPResponse;
import com.amazonaws.services.lambda.runtime.events.KinesisEvent;
import com.amazonaws.services.lambda.runtime.events.S3Event;
import com.amazonaws.services.lambda.runtime.events.SNSEvent;
import com.amazonaws.services.lambda.runtime.events.SQSEvent;
import com.amazonaws.services.lambda.runtime.serialization.PojoSerializer;
import com.amazonaws.services.lambda.runtime.serialization.events.LambdaEventSerializers;
import com.fasterxml.jackson.core.JsonParser;
@@ -76,13 +70,13 @@ final class AWSLambdaUtils {
}
private static boolean isSupportedAWSType(Type inputType) {
Class<?> inputClass = FunctionTypeUtils.getRawType(inputType);
return APIGatewayV2HTTPEvent.class.isAssignableFrom(inputClass)
|| S3Event.class.isAssignableFrom(inputClass)
|| APIGatewayProxyRequestEvent.class.isAssignableFrom(inputClass)
|| SNSEvent.class.isAssignableFrom(inputClass)
|| SQSEvent.class.isAssignableFrom(inputClass)
|| KinesisEvent.class.isAssignableFrom(inputClass);
String typeName = inputType.getTypeName();
return typeName.equals("com.amazonaws.services.lambda.runtime.events.APIGatewayV2HTTPEvent")
|| typeName.equals("com.amazonaws.services.lambda.runtime.events.S3Event")
|| typeName.equals("com.amazonaws.services.lambda.runtime.events.APIGatewayProxyRequestEvent")
|| typeName.equals("com.amazonaws.services.lambda.runtime.events.SNSEvent")
|| typeName.equals("com.amazonaws.services.lambda.runtime.events.SQSEvent")
|| typeName.equals("com.amazonaws.services.lambda.runtime.events.KinesisEvent");
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@@ -182,12 +176,14 @@ final class AWSLambdaUtils {
ObjectMapper objectMapper, Type functionOutputType) {
Class<?> outputClass = FunctionTypeUtils.getRawType(functionOutputType);
if (outputClass != null && (APIGatewayV2HTTPResponse.class.isAssignableFrom(outputClass)
|| APIGatewayProxyResponseEvent.class.isAssignableFrom(outputClass))) {
return responseMessage.getPayload();
if (outputClass != null) {
String outputClassName = outputClass.getName();
if (outputClassName.equals("com.amazonaws.services.lambda.runtime.events.APIGatewayV2HTTPResponse") ||
outputClassName.equals("com.amazonaws.services.lambda.runtime.events.APIGatewayProxyResponseEvent")) {
return responseMessage.getPayload();
}
}
if (!objectMapper.isEnabled(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES)) {
configureObjectMapper(objectMapper);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2019-2019 the original author or authors.
* Copyright 2019-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,6 +28,7 @@ import org.springframework.core.env.MapPropertySource;
* Adds default properties to the environment for running a custom runtime in AWS.
*
* @author Dave Syer
* @author Oleg Zhurakousky
*/
public class CustomRuntimeEnvironmentPostProcessor implements EnvironmentPostProcessor {
@@ -38,12 +39,6 @@ public class CustomRuntimeEnvironmentPostProcessor implements EnvironmentPostPro
SpringApplication application) {
if (!environment.containsProperty(CUSTOM_RUNTIME)) {
Map<String, Object> defaults = getDefaultProperties(environment);
defaults.putIfAbsent("spring.cloud.function.web.export.source.url",
"http://${AWS_LAMBDA_RUNTIME_API:localhost}/2018-06-01/runtime/invocation/next");
defaults.putIfAbsent("spring.cloud.function.web.export.sink.url",
"http://${AWS_LAMBDA_RUNTIME_API:localhost}/2018-06-01/runtime/invocation/{{destination}}/response");
defaults.put("spring.cloud.function.web.export.sink.name",
"origin|${_HANDLER:}");
defaults.put(CUSTOM_RUNTIME, true);
}
}