-
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
2.14.0.CR1 Class with @Provider and @RequestScoped annotations causes build failure #28889
Comments
@bcluap thanks for the report. A reproducer would be welcome. |
I'll see what I can do. A bit swamped today but will get something to you |
I won't be around until Monday to look at this. Also cc @Sgitario |
Also cc @manovotn who might have made a related change |
Reproducer: |
I will revert it if we can't find a solution by then. |
Yeah, that makes perfect sense. |
So, the problem lies with this code - https://github.com/quarkusio/quarkus/blob/main/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/main/java/io/quarkus/resteasy/reactive/server/deployment/ResteasyReactiveProcessor.java#L730-L790 We limit bean types of RestEasy classes (such as those with @bcluap note that the reproducer app can be made to work if you instead inject the exact class, i.e. instead of I am not yet sure how to fix this. We need type restriction if the instance factory should behave according to CDI rules but that inevitably breaks scenarios such as the one presented here... |
Well, I'm not sure it's a good idea to use a bean class that implements the |
I didn't want to judge that because I am not a RE expert so I have no idea if this common case or not; @geoand might know more. As for solutions:
Personally, I'd lean towards 3. with this case. |
Yeah, this is indeed weird - it would only work in Quarkus and not in any other JAX-RS / CDI implementation. It's not something we have ever said we support, it worked previously by accident. If we are going to disallow this case, #28429 needs to be a breaking change (I added the label) |
I'd like to hear from @bcluap on the reasoning behind using this particular pattern |
Hi All,
So this weird scenario I have actually came from a discussion with most of
you a few years back. Check on quarkus-dev for topic "Injecting @context
HttpHeaders at instance level on @RequestScoped"
I was trying to find a way to be able to inject JAX-RS stuff using Quakus
and this solution presented itself and has been working great. In fact if
you search quarkus-dev and tulip you will find its been a suggestion for
quite a few people who have wanted to inject things based on
ContainerRequestContext.
…On Mon, Oct 31, 2022 at 12:15 PM Georgios Andrianakis < ***@***.***> wrote:
I'd like to hear from @bcluap <https://github.com/bcluap> on the
reasoning behind using this particular pattern
—
Reply to this email directly, view it on GitHub
<#28889 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AGMB23P6ASXEYJXX4G3NZVLWF6L5BANCNFSM6AAAAAARQJXYFY>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Thanks for that info! Given that this kind of thing is no longer necessary (as RR fuses CDI and JAX-RS seamlessly), I am personally in favor of dropping support for this. |
… On Mon, Oct 31, 2022 at 12:50 PM Georgios Andrianakis < ***@***.***> wrote:
Thanks for that info!
Given that this kind of thing is no longer necessary (as RR fuses CDI and
JAX-RS seamlessly), I am personally in favor of dropping support for this.
—
Reply to this email directly, view it on GitHub
<#28889 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AGMB23P6BNHHSMLSUBAMTTLWF6P5TANCNFSM6AAAAAARQJXYFY>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Indeed But you essentially want to access |
Yea, but a bit more than that. Here are the things we use it for:
containerRequestContext.getUriInfo();
containerRequestContext.getHeaderString(name);
containerRequestContext.getHeaders();
containerRequestContext.getProperty(name);
containerRequestContext.setProperty(name, value);
containerRequestContext.getPropertyNames()
containerRequestContext.getAcceptableLanguages()
…On Mon, Oct 31, 2022 at 1:02 PM Georgios Andrianakis < ***@***.***> wrote:
Indeed ContainerRequestContext is not a bean type, so it's not eligible
for injection.
But you essentially want to access HttpHeaders, correct?
—
Reply to this email directly, view it on GitHub
<#28889 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AGMB23NYOC4GDIYW42EUUTTWF6RMDANCNFSM6AAAAAARQJXYFY>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
I've added @typed({RequestContextImpl.class, RequestContext.class}) and it
works and our tests pass on 2.14.0.CR1 so that's great news.
As for this ticket, happy for it to be closed but I do just with that there
was a clean way of getting hold of RequestContext without passing it
around. It just makes so much sense for this to be injectable as a
RequestScoped bean, even if its not what the specs say. Maybe RR could have
something like this enabled. Dunno just wondering but for us we are sorted.
Thanks guys.
…On Mon, Oct 31, 2022 at 1:07 PM Paul Carter-Brown ***@***.***> wrote:
Yea, but a bit more than that. Here are the things we use it for:
containerRequestContext.getUriInfo();
containerRequestContext.getHeaderString(name);
containerRequestContext.getHeaders();
containerRequestContext.getProperty(name);
containerRequestContext.setProperty(name, value);
containerRequestContext.getPropertyNames()
containerRequestContext.getAcceptableLanguages()
On Mon, Oct 31, 2022 at 1:02 PM Georgios Andrianakis <
***@***.***> wrote:
> Indeed ContainerRequestContext is not a bean type, so it's not eligible
> for injection.
>
> But you essentially want to access HttpHeaders, correct?
>
> —
> Reply to this email directly, view it on GitHub
> <#28889 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AGMB23NYOC4GDIYW42EUUTTWF6RMDANCNFSM6AAAAAARQJXYFY>
> .
> You are receiving this because you were mentioned.Message ID:
> ***@***.***>
>
|
#28946 will allow you to inject |
Georgios, you really never fail to amaze me :-)
…On Mon, Oct 31, 2022 at 1:23 PM Georgios Andrianakis < ***@***.***> wrote:
#28946 <#28946> will allow you
to inject ContainerRequestContext directly
—
Reply to this email directly, view it on GitHub
<#28889 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AGMB23N22JPK7DUHOW7N2ADWF6T43ANCNFSM6AAAAAARQJXYFY>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Hahaha ❤️ The community makes all this possible :) |
Add the ability to inject ContainerRequestContext via CDI
Closes: quarkusio#28889 (cherry picked from commit 6fffa79)
When changing from 2.13.3.Final to 2.14.0.CR1 Quarkus build fails on our project:
The full list of errors is huge but all relate to injecting com.ukheshe.arch.rest.RequestContext
The implementation of this class is slightly unique in that it looks like this:
If I remove the @Provider annotation then the build succeeds but the application has issues because this class needs to be a ContainerRequestFilter to get the requestContext and use it when this RequestScoped bean is injected.
Not sure if 2.14 has changed something and wont properly process beans that have both @Provider and @RequestScoped
The text was updated successfully, but these errors were encountered: