You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
pdating AwsProxyHttpServletResponseWriter.java
Fix provided for #497
This is to resolve NullPointerException when HttpStatusCode is not present in default enum Response.StatusType
To help us debug your issue fill in the basic information below using the options provided
Serverless Java Container version:
1.9
Implementations:
Jersey
Framework version:
jersey-media-json-jackson : 2.37
Frontend service:
ALB
Deployment method:
Console
Scenario
I am trying to return 422 statusCode in specific scenario using javax.ws.rs.core Response.status(422).entity(response).build();
Expected behavior
It should through exception with status 422
Actual behavior
502Bad Gateway
{
"message": "Gateway timeout"
}
Steps to reproduce
Full log output
"java.lang.NullPointerException: null\n\tat com.amazonaws.serverless.proxy.internal.servlet.AwsProxyHttpServletResponseWriter.writeResponse(AwsProxyHttpServletResponseWriter.java:77)\n\tat com.amazonaws.serverless.proxy.internal.servlet.AwsProxyHttpServletResponseWriter.writeResponse(AwsProxyHttpServletResponseWriter.java:36)\n\tat com.amazonaws.serverless.proxy.internal.LambdaContainerHandler.proxy(LambdaContainerHandler.java:222)\n\tat com.amazonaws.serverless.proxy.internal.LambdaContainerHandler.proxyStream(LambdaContainerHandler.java:257)\n\tat com.telstra.digitalservices.lambda.Handler.handleRequest(Handler.java:42)\n\tat java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\n\tat java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)\n\tat java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)\n\tat java.base/java.lang.reflect.Method.invoke(Unknown Source)\n\tat lambdainternal.EventHandlerLoader$StreamMethodRequestHandler.handleRequest(EventHandlerLoader.java:375)\n\tat lambdainternal.EventHandlerLoader$2.call(EventHandlerLoader.java:899)\n\tat lambdainternal.AWSLambda.startRuntime(AWSLambda.java:268)\n\tat lambdainternal.AWSLambda.startRuntime(AWSLambda.java:206)\n\tat lambdainternal.AWSLambda.main(AWSLambda.java:200)\n"
As per analysis it's failing while getting reason phrase on
https://github.com/awslabs/aws-serverless-java-container/blob/main/aws-serverless-java-container-core/src/main/java/com/amazonaws/serverless/proxy/internal/servlet/AwsProxyHttpServletResponseWriter.java#L77
422 is not present by default in provided enum , so fromStatusCode(int statusCode) is returning null as per its implementation
public static Status fromStatusCode(int statusCode) {
for (Status s : values()) {
if (s.code == statusCode) {
return s;
}
}
return null;
}
And null.getReasonPhrase is causing this nullPointerException.
Could you please suggest ways to handle this?
The text was updated successfully, but these errors were encountered: