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

IfBuildProperty on classes with ServerRequestFilter causes build to fail #29115

Closed
Postremus opened this issue Nov 8, 2022 · 3 comments · Fixed by #29118
Closed

IfBuildProperty on classes with ServerRequestFilter causes build to fail #29115

Postremus opened this issue Nov 8, 2022 · 3 comments · Fixed by #29118
Assignees
Labels
area/resteasy-reactive kind/bug Something isn't working
Milestone

Comments

@Postremus
Copy link
Member

Postremus commented Nov 8, 2022

Describe the bug

I have a ServerRequestFilter, which I only need to be active sometimes.
I therefore wanted to deactivate it by default with @IfBuildProperty.

@ApplicationScoped
@IfBuildProperty(name = "notexistingproperty", stringValue = "true")
public class MagicFilter {

    @ServerRequestFilter(priority = 0, preMatching = true)
    public void getFilter(HttpServerRequest request) {
        //TODO: do something..
    }
}

However, this results in the exception from below.

Expected behavior

I can remove this bean with IfBuildProperty.

Actual behavior

C:\workspaces\aviator\filter-ifproperty>mvn clean install
[INFO] Scanning for projects...
[INFO] 
[INFO] ---------------------< org.acme:filter-ifproperty >---------------------
[INFO] Building filter-ifproperty 1.0.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ filter-ifproperty ---
[INFO] Deleting C:\workspaces\aviator\filter-ifproperty\target
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ filter-ifproperty ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO] 
[INFO] --- quarkus-maven-plugin:2.13.4.Final:generate-code (default) @ filter-ifproperty ---
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ filter-ifproperty ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 2 source files to C:\workspaces\aviator\filter-ifproperty\target\classes
[INFO] 
[INFO] --- quarkus-maven-plugin:2.13.4.Final:generate-code-tests (default) @ filter-ifproperty ---
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ filter-ifproperty ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\workspaces\aviator\filter-ifproperty\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ filter-ifproperty ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ filter-ifproperty ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ filter-ifproperty ---
[INFO] Building jar: C:\workspaces\aviator\filter-ifproperty\target\filter-ifproperty-1.0.0-SNAPSHOT.jar
[INFO] 
[INFO] --- quarkus-maven-plugin:2.13.4.Final:build (default) @ filter-ifproperty ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  7.388 s
[INFO] Finished at: 2022-11-08T07:02:41+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal io.quarkus.platform:quarkus-maven-plugin:2.13.4.Final:build (default) on project filter-ifproperty: Failed to build quarkus application: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
[ERROR]         [error]: Build step io.quarkus.arc.deployment.ArcProcessor#validate threw an exception: javax.enterprise.inject.spi.DeploymentException: javax.enterprise.inject.UnsatisfiedResolutionException: Unsatisfied dependency for type org.acme.MagicFilter and qualifiers [
@Default]
[ERROR]         - java member: org.acme.MagicFilter$GeneratedServerRequestFilter$getFilter():arg0
[ERROR]         - declared on CLASS bean [types=[javax.ws.rs.container.ContainerRequestFilter, org.acme.MagicFilter$GeneratedServerRequestFilter$getFilter, java.lang.Object], qualifiers=[@Default, @Any], target=org.acme.MagicFilter$GeneratedServerRequestFilter$getFilter]       
[ERROR]         at io.quarkus.arc.processor.BeanDeployment.processErrors(BeanDeployment.java:1217)
[ERROR]         at io.quarkus.arc.processor.BeanDeployment.init(BeanDeployment.java:287)
[ERROR]         at io.quarkus.arc.processor.BeanProcessor.initialize(BeanProcessor.java:143)
[ERROR]         at io.quarkus.arc.deployment.ArcProcessor.validate(ArcProcessor.java:517)
[ERROR]         at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
[ERROR]         at java.base/java.lang.reflect.Method.invoke(Method.java:578)
[ERROR]         at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:909)
[ERROR]         at io.quarkus.builder.BuildContext.run(BuildContext.java:281)
[ERROR]         at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
[ERROR]         at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
[ERROR]         at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
[ERROR]         at java.base/java.lang.Thread.run(Thread.java:1589)
[ERROR]         at org.jboss.threads.JBossThread.run(JBossThread.java:501)
[ERROR] Caused by: javax.enterprise.inject.UnsatisfiedResolutionException: Unsatisfied dependency for type org.acme.MagicFilter and qualifiers [@Default]
[ERROR]         - java member: org.acme.MagicFilter$GeneratedServerRequestFilter$getFilter():arg0
[ERROR]         - declared on CLASS bean [types=[javax.ws.rs.container.ContainerRequestFilter, org.acme.MagicFilter$GeneratedServerRequestFilter$getFilter, java.lang.Object], qualifiers=[@Default, @Any], target=org.acme.MagicFilter$GeneratedServerRequestFilter$getFilter]       
[ERROR]         at io.quarkus.arc.processor.Beans.resolveInjectionPoint(Beans.java:440)
[ERROR]         at io.quarkus.arc.processor.BeanInfo.init(BeanInfo.java:539)
[ERROR]         at io.quarkus.arc.processor.BeanDeployment.init(BeanDeployment.java:275)
[ERROR]         ... 11 more
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

How to Reproduce?

Download the reproducer:
filter-ifproperty.zip

mvn clean install
exception from above happens

When you now remove the IfBuildProperty annotation from the MagicFIlter class, and build the project again, it works.

Output of uname -a or ver

Microsoft Windows [Version 10.0.19044.2130]

Output of java -version

openjdk 19 2022-09-20 OpenJDK Runtime Environment Temurin-19+36 (build 19+36) OpenJDK 64-Bit Server VM Temurin-19+36 (build 19+36, mixed mode, sharing)

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.13.4.Final

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.8.4 (9b656c72d54e5bacbed989b64718c159fe39b537) Maven home: C:\eclipse\tools\java\maven Java version: 19, vendor: Eclipse Adoptium, runtime: C:\eclipse\tools\java\19 Default locale: de_DE, platform encoding: UTF-8 OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

Additional information

No response

@Postremus Postremus added the kind/bug Something isn't working label Nov 8, 2022
@quarkus-bot quarkus-bot bot added env/windows Impacts Windows machines triage/needs-triage labels Nov 8, 2022
@quarkus-bot
Copy link

quarkus-bot bot commented Nov 8, 2022

/cc @FroMage, @geoand, @stuartwdouglas

@geoand
Copy link
Contributor

geoand commented Nov 8, 2022

Interesting as I never thought of this combination...

Let me see what can be done

@geoand
Copy link
Contributor

geoand commented Nov 8, 2022

#29118 takes care of the root cause.

However there is still a problem if you use @ApplicationScoped (but that is something totally separate and it should not be necessary to use that anyway).

geoand added a commit that referenced this issue Nov 8, 2022
Take conditional annotations into account for Request and Response filters
@quarkus-bot quarkus-bot bot added this to the 2.15 - main milestone Nov 8, 2022
@gsmet gsmet modified the milestones: 2.15 - main, 2.14.1.Final Nov 10, 2022
gsmet pushed a commit to gsmet/quarkus that referenced this issue Nov 10, 2022
pedroh-pereira pushed a commit to pedroh-pereira/quarkus that referenced this issue Nov 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/resteasy-reactive kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants