-
Notifications
You must be signed in to change notification settings - Fork 561
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PUT request with no body fails (Jersey) #147
Comments
Mh, I cannot reproduce in local with a unit test. My resource is defined like this: @Path("/empty-stream/{paramId}") @PUT
@Produces(MediaType.APPLICATION_JSON)
public Response emptyStream(@PathParam("paramId") String paramId) {
SingleValueModel sv = new SingleValueModel();
sv.setValue(paramId);
return Response.ok(sv).build();
} The test is defined like this: @Test
public void emptyStream_putNullBody_expectPutToSucceed() {
AwsProxyRequest request = new AwsProxyRequestBuilder("/echo/empty-stream/" + QUERY_STRING_KEY, "PUT").body(null).build();
AwsProxyResponse resp = handler.proxy(request, lambdaContext);
assertEquals(200, resp.getStatusCode());
} I'm getting a |
Hey @boardthatpowder, any hint you can give me on this? |
Closing since I haven't heard back from @boardthatpowder. If you are still running into this issue with the latest version - |
Hi, Our handling code looks like this: @Override
public void handleRequest(InputStream input, OutputStream output, Context context) {
HANDLER.proxyStream(input, output, context);
} And the stack trace at our jersey unhandled exceptions mapper: Unhandled exception: java.io.IOException: Read after end of file
at org.apache.commons.io.input.NullInputStream.read(NullInputStream.java:189)
at com.amazonaws.serverless.proxy.internal.servlet.AwsProxyHttpServletRequest$AwsServletInputStream.read(AwsProxyHttpServletRequest.java:895)
at java.io.InputStream.read(InputStream.java:170)
at org.glassfish.jersey.message.internal.EntityInputStream.read(EntityInputStream.java:79)
at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$UnCloseableInputStream.read(ReaderInterceptorExecutor.java:273)
at com.fasterxml.jackson.core.json.ByteSourceJsonBootstrapper.ensureLoaded(ByteSourceJsonBootstrapper.java:522)
[........]
at xxxxxxxxxxx.LambdaHandler.handleRequest(LambdaHandler.java:215) It seems that We use apache commons-io 2.6 (latest) |
Thanks @eduramiba. Let me reopen this. I'll look into it over the next couple of days. |
I still can't seem to replicate the issue you are seeing. This unit test succeeds. Regardless, seems like a sensible idea to put a null guard around that read operation from the input stream so I will make that change. |
Release 1.3.2 - which includes this fix - is on its way to maven central! Resolving this issue. |
Thank you! |
Scenario
REST PUT requests for managing relationships between resources generally have no request body compared with REST PUT requests that manage updating resource attributes do.
Attempting a REST PUT with no request body fails. This was working in framework version 0.7.
Expected behavior
REST PUT with no body returns successfully.
Actual behavior
Fails with
java.io.IOException: Read after end of file
exception.Steps to reproduce
Create controller:
Executer request
PUT /parent/A/child/B
with no request body.Full log output
The text was updated successfully, but these errors were encountered: