Description
Serverless Java Container version: 2.0.2
Implementations: Spring Boot 3
Framework version: SpringBoot 3.2.6.RELEASE
Frontend service: ALB|RestController
Deployment method: AWS Cloud Development Kit
Scenario
We tried to migrate the server less java container spring boot version we are using from version 2.0.1 to 2.0.2. We are using the framework for our lambda which is accessible by an alb, which has a certain target groups, that directs the calls to the corresponding lambda. The lambda provides a spring @RestController with Post and Get Mappings. With version 2.0.1 everything worked fine.
Expected behavior
By increasing the version in the build gradle dependencies, we wanted to migrate to the new version without any additional workaround or further action.
Actual behavior
When multi-header value (attribute on target group of lambda: lambda.multi_value_headers.enabled
) are configured in the alb, the requests directing to lambda are answered with HTTP status code 502. The error occurs, when the lambda should be invoked by a HTTP request to its endpoints. Please see stack trace in full log output.
Steps to reproduce
Create a lambda with corresponding 2.0.2 version of framework, that is invoked by an alb and target group that the user can the endpoint provided by the lambdas @RestController. The multi-value headers need to be activated at the target group level.
For the setup description in https://github.com/aws/serverless-java-container/wiki/Quick-start---Spring-Boot3 is used as template.
Full log output
java.lang.NullPointerException: Cannot invoke "com.amazonaws.serverless.proxy.model.SingleValueHeaders.get(Object)" because the return value of "com.amazonaws.serverless.proxy.model.AwsProxyRequest.getHeaders()" is null
at com.amazonaws.serverless.proxy.internal.servlet.AwsProxyHttpServletRequest.getRemoteHost(AwsProxyHttpServletRequest.java:450)
at org.springframework.http.server.reactive.ServletServerHttpRequest.getRemoteAddress(ServletServerHttpRequest.java:192)
at org.springframework.http.server.reactive.DefaultServerHttpRequestBuilder.<init>(DefaultServerHttpRequestBuilder.java:76)
at org.springframework.http.server.reactive.ServerHttpRequest.mutate(ServerHttpRequest.java:106)
at org.springframework.http.server.reactive.ContextPathCompositeHandler.lambda$handle$1(ContextPathCompositeHandler.java:73)
at java.base/java.util.Optional.map(Unknown Source)
at org.springframework.http.server.reactive.ContextPathCompositeHandler.handle(ContextPathCompositeHandler.java:71)
at org.springframework.boot.web.reactive.context.WebServerManager$DelayedInitializationHttpHandler.handle(WebServerManager.java:98)
at org.springframework.http.server.reactive.ServletHttpHandlerAdapter.service(ServletHttpHandlerAdapter.java:199)
at com.amazonaws.serverless.proxy.spring.embedded.ServerlessReactiveServletEmbeddedServerFactory.service(ServerlessReactiveServletEmbeddedServerFactory.java:71)
at com.amazonaws.serverless.proxy.internal.servlet.FilterChainManager$ServletExecutionFilter.doFilter(FilterChainManager.java:374)
at com.amazonaws.serverless.proxy.internal.servlet.FilterChainHolder.doFilter(FilterChainHolder.java:90)
at com.amazonaws.serverless.proxy.internal.servlet.AwsLambdaServletContainerHandler.doFilter(AwsLambdaServletContainerHandler.java:154)
at com.amazonaws.serverless.proxy.spring.SpringBootLambdaContainerHandler.handleRequest(SpringBootLambdaContainerHandler.java:183)
at com.amazonaws.serverless.proxy.spring.SpringBootLambdaContainerHandler.handleRequest(SpringBootLambdaContainerHandler.java:56)
at com.amazonaws.serverless.proxy.internal.LambdaContainerHandler.proxy(LambdaContainerHandler.java:215)
at com.amazonaws.serverless.proxy.internal.LambdaContainerHandler.proxyStream(LambdaContainerHandler.java:258)
at com.example.myapplication.StreamLambdaHandler.handleRequest(StreamLambdaHandler.kt:33)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at com.amazonaws.services.lambda.runtime.api.client.EventHandlerLoader$StreamMethodRequestHandler.handleRequest(EventHandlerLoader.java:379)
at com.amazonaws.services.lambda.runtime.api.client.EventHandlerLoader$2.call(EventHandlerLoader.java:907)
at com.amazonaws.services.lambda.runtime.api.client.AWSLambda.startRuntime(AWSLambda.java:239)
at com.amazonaws.services.lambda.runtime.api.client.AWSLambda.startRuntime(AWSLambda.java:191)
at com.amazonaws.services.lambda.runtime.api.client.AWSLambda.main(AWSLambda.java:181)