Skip to content
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

@UnlessBuildProfile not working as expected #16243

Closed
rareddy opened this issue Apr 5, 2021 · 11 comments
Closed

@UnlessBuildProfile not working as expected #16243

rareddy opened this issue Apr 5, 2021 · 11 comments
Labels
area/arc Issue related to ARC (dependency injection) kind/bug Something isn't working triage/invalid This doesn't seem right

Comments

@rareddy
Copy link

rareddy commented Apr 5, 2021

Describe the bug

When @UnlessBuildProfile used on @ApplicationScoped bean, there are a couple of issues I am seeing.

  1. When you build a profile that does not match to the annotation, even in that profile the bean is available.
  2. When the bean is available it does not do the @Inject operations correctly.

for example, I have @UnlessBuildProfile("prod"), and when building the prod I still see the bean available. I could verify that because in my case it is rest controller.

Expected behavior

The bean be not available

To Reproduce

@ApplicationScoped
@UnlessBuildProfile("prod")
@Path("/")
public class MockControlPlane {

  public String hello(){
     return "hello";
  } 
}

build with -Dquarkus.profile=prod

@FroMage
Copy link
Member

FroMage commented Apr 6, 2021

CC @mkouba

@FroMage FroMage added area/arc Issue related to ARC (dependency injection) and removed triage/needs-triage labels Apr 6, 2021
@FroMage
Copy link
Member

FroMage commented Apr 6, 2021

Actually, I wonder if this is not a combination of RESTEasy scanning and taking over discovery because CDI would not claim that bean?

@mkouba
Copy link
Contributor

mkouba commented Apr 6, 2021

Actually, I wonder if this is not a combination of RESTEasy scanning and taking over discovery because CDI would not claim that bean?

Yes, I think so. The bean is not registered but there's a fallback used in the QuarkusInjectorFactory that just creates the resource instance via new MockControlPlane() and that's why CDI injection does not work there.

@mkouba
Copy link
Contributor

mkouba commented Apr 6, 2021

TBH I'm not sure what the correct behavior would be but I think that the fallback is there since the beginning (and an "invisible" DEBUG message is logged).

@mkouba
Copy link
Contributor

mkouba commented Apr 6, 2021

CC @geoand

@geoand
Copy link
Contributor

geoand commented Apr 6, 2021

Yeah, I think what you guys mention is what is going on

@FroMage
Copy link
Member

FroMage commented Apr 6, 2021

So perhaps RESTEasy Classic and Reactive should both special-case @UnlessBuildProfile?

@geoand
Copy link
Contributor

geoand commented Apr 6, 2021

That will likely be needed

@geoand
Copy link
Contributor

geoand commented Apr 6, 2021

This actually should be working as we have merged: #15215

So I'll need to have another look

@rareddy
Copy link
Author

rareddy commented Apr 6, 2021

I am using 1.11.1.Final version of Quarkus if the above is after that I would need validate with a newer release

@geoand
Copy link
Contributor

geoand commented Apr 6, 2021

OK, that explains it then, as I just tried with the latest and it works.

So you need to use 1.13.0.Final or newer to get this feature

@geoand geoand closed this as completed Apr 6, 2021
@geoand geoand added the triage/invalid This doesn't seem right label Apr 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/arc Issue related to ARC (dependency injection) kind/bug Something isn't working triage/invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

4 participants