-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
[resteasy-reactive] [3.8.6] Header not reset between request #45789
Comments
/cc @FroMage (rest), @geoand (rest), @stuartwdouglas (rest) |
|
Probably a request scope is missing, for smallrye-jwt we started failing builds when non-proxiable types like String are injected into application scoped beans |
Ah good point @sberyozkin , String is indeed not proxyable! |
Everything works file if you make |
The solution is to declared the class as @RequestScoped
@Path("/hello")
public class GreetingResource {
@HeaderParam("filter")
String filter;
@GET
@Produces(MediaType.TEXT_PLAIN)
public String hello() {
return "Header: %s".formatted(filter);
}
} Or @Path("/hello")
public class GreetingResource {
@GET
@Produces(MediaType.TEXT_PLAIN)
public String hello(@HeaderParam("filter") String filter) {
return "Header: %s".formatted(filter);
}
} |
This is always the better option |
Wow that's scary. This should be an error. Any request-scoped value injected into fields in a non-request-scoped bean should be rejected at build time. All Otherwise, given an application-scoped bean, we will inject parameter fields left and right on the same objects while requests are happening, leading to huge breakage, since we handle this sort of injection ourselves. Pretty amazing this never manifested earlier 😱 |
I agree |
@FroMage do you want to make this a build failure? It goes without saying that we can't backport it as it's a breaking change. |
+1 to fail on build, as it's a programming error. Bonus points if the IDE plugin could detect that |
Definitely a build failure. This is way too dangerous to be allowed. We should break older applications by backporting it. The risk is pretty huge. But also, is it normal that we default to anything else besides |
That was one of my proposals for fixing this |
Describe the bug
When a header is injected directy in a Endpoint class, this header is not clean between two request.
Exemple:
On first call without the header
filter
, the value offilter
isnull
.On second call with the header
filter
with the value 'my filter', the value offilter
is 'my filter'.On third call without the header
filter
, the value offilter
is 'my filter'.FI: I have the same issue with the 3.15.3
Expected behavior
On third call without the header
filter
, the value should benull
.Actual behavior
The third call keep the value of the second one
How to Reproduce?
repro-header.zip
Small reproducer. Use the
/hello
with a headerheader
once with a value, and without a value.Output of
uname -a
orver
No response
Output of
java -version
openjdk version "17.0.12" 2024-07-16
Quarkus version or git rev
3.8.6
Build tool (ie. output of
mvnw --version
orgradlew --version
)apache-maven-3.9.0
Additional information
No response
The text was updated successfully, but these errors were encountered: