-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Using raw RestResponse
return type has unexpected consequences
#28627
Comments
/cc @FroMage, @geoand, @stuartwdouglas |
We'll should wait for #27526 to be merged before addressing this one |
I just noticed that if I supply a generic type parameter (I hadn't noticed that ❯ curl http://localhost:8080/hello/file2 -i
HTTP/1.1 200 OK
content-length: 322
Content-Type: multipart/form-data
--2b496fef-3c0a-469e-89f3-2ff04b5355d1
Content-Disposition: form-data; name="file"; filename="test.txt"
Content-Type: application/octet-stream
test test
--2b496fef-3c0a-469e-89f3-2ff04b5355d1
Content-Disposition: form-data; name="name"
Content-Type: text/plain
test.txt
--2b496fef-3c0a-469e-89f3-2ff04b5355d1-- rather than: ❯ curl http://localhost:8080/hello/file2 -i
HTTP/1.1 200 OK
content-length: 34
Content-Type: multipart/form-data
org.acme.DownloadFormData@20accfa0 I suppose that would be a good reason to log a warning (or even an error) at build-time if there is no generic type parameter. Yet, as you may notice, the ❯ curl http://localhost:8080/hello/file -i
HTTP/1.1 200 OK
content-length: 322
Content-Type: multipart/form-data;boundary=736e7384-ca9b-4c3b-8cec-5231fe5e1d00
--736e7384-ca9b-4c3b-8cec-5231fe5e1d00
Content-Disposition: form-data; name="file"; filename="test.txt"
Content-Type: application/octet-stream
test test
--736e7384-ca9b-4c3b-8cec-5231fe5e1d00
Content-Disposition: form-data; name="name"
Content-Type: text/plain
test.txt
--736e7384-ca9b-4c3b-8cec-5231fe5e1d00-- The only difference being the @geoand I propose to change this issue to log a warning when an endpoint returns |
I went ahead and filed #28634 for the problem regarding the |
RestResponse
cannot be used for multipart/form-data
responsesRestResponse
return type has unexpected consequences
👍🏼 |
What's weird is that the |
When I first looked at it, I was under the impression that this check should maybe also check for Line 396 in 3b2e75e
I could put that theory to the test. |
We should definitely at least log a warning. |
#28657 adds a warning |
Provide a warning when a raw RestResponse return type is used
Closes: quarkusio#28627 (cherry picked from commit ed806c8)
Closes: quarkusio#28627 (cherry picked from commit ed806c8)
Describe the bug
Specifying the raw
RestResponse
type as an endpoint's return type causes Quarkus to configure theServerStringMessageBodyHandler
for this endpoint. This will most often not be what the user wants.In the following example, where the endpoint returns
multipart/form-data
responses, but has the rawRestResponse
type as its return type, the POJO entity gets serialized using itstoString()
method rather than usingMultipartMessageBodyWriter
:The use case for returning
RestResponse
is to allow dynamically setting response headers, as documented. Of course the return type should be specified with a generic type parameter.Expected behavior
Since
RestResponse
is the counterpart of the JAX-RSResponse
type, which isn't generic, I think it would make sense if Quarkus would log a build-time usage warning, whenever an endpoint returns the rawRestResponse
type.Actual behavior
Currently there is no warning and Quarkus will "silently" configure the
ServerStringMessageBodyHandler
.How to Reproduce?
Create an endpoint with
RestResponse
as the return type.Output of
uname -a
orver
No response
Output of
java -version
No response
GraalVM version (if different from Java)
No response
Quarkus version or git rev
2.13.2.Final
Build tool (ie. output of
mvnw --version
orgradlew --version
)No response
Additional information
No response
The text was updated successfully, but these errors were encountered: