-
Notifications
You must be signed in to change notification settings - Fork 264
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
Quarkus Resteasy endpoint returning 500 to client after HEAD request because of Logbook NullPointerException #1384
Comments
I'm constantly surprised that developers use The proper fix, imho, would be to catch the null case in
|
From the specs
Guess this is most of the time interpreted by a language-specific |
Yeah, but implementation wise an empty stream bytes is a perfectly reasonable way to represent an empty response. For reference: https://refactoring.guru/introduce-null-object |
Thank you for the resource. return Response.ok(new Object()).build(); will anyway throw an excpection, so I guess it is something happening with Resteasy-Quarkus. |
Hello, |
Hi @fenix-hub I tried to reproduce the issue (using newer versions of Logbook and Quarkus). Here's the project: Please see the As such, I'm closing the issue as not-reproducible. Please feel free to re-open it with a link to a GitHub repository that reproduces the issue. (In doing so, please use the updated version of Logbook and Quarkus). |
@msdousti Thank you very much for your example project and for answering this issue, Though it works with newer verisons of Logbook and (especially) Quarkus, Would this also work with Quarkus 2 (non reactive)? |
You're welcome! I'm not super familiar with Quarkus; you can try creating a toy project with Quarkus If it fails with 500 error, please post the GitHub link here for me to investigate. Please make sure the following is set up (I provided link to my toy project): |
Here's a repo for exactly the same versions as you mentioned in the ticket: |
Addressed by #1909 |
I'm writing a webservice using Logbook to log requests and responses in a Quarkus application.
I'm using Resteasy implementation for the RESTful endpoints.
Exposing an
@HEAD
endpoint causes Logbook to throw aNullPointerException
right after logging the response.Even though the request is sucessfully handled, whatever the response code is (be it
200
or404
) the exception causes the client to not receive the webservice response, instead 500 is received.Description
By my understanding, Logbook uses
TeeStream
to overcome the request/response stream to be emptied on requests and responses.This is default behavior at least; however this should not be always done, because of some requests type not supporting (or not expecting) a response body to be returned by standard.
An
HEAD
request is one of these.Expected Behavior
Logbook should just log request/response flow without trying to catch bodies in
HEAD
requests, eventually directly inspecting the body itself or just checking if theContent-Type
header is present (it isn't forHEAD
requests).Actual Behavior
Logbook logs request/response correctly, but a
NullPointerException
is thrown and causes any client to receive 500 instead of the actual response.Stacktrace
Possible Fix
Don't look for a response body for HEAD requests.
Instead of directly targeting the request method, the body logging could be skipped because of missing the
Content-Type
header or if the response is just null.Steps to Reproduce
Your Environment
Version used:
The text was updated successfully, but these errors were encountered: