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

Combination of rest-client and smallrye-opentracing ends with NPE when running generated tests #22605

Closed
rsvoboda opened this issue Jan 4, 2022 · 2 comments · Fixed by #22609

Comments

@rsvoboda
Copy link
Member

rsvoboda commented Jan 4, 2022

Describe the bug

Combination of rest-client and smallrye-opentracing ends with NPE when running generated tests

Using Quarkus 2.6.1.Final, test is passing when smallrye-opentracing is commented out.
Seems this is not a new regression, was able to reproduce on Quarkus 2.2.5.Final.

[INFO] Running io.quarkus.qe.MyRemoteServiceTest
2022-01-04 09:55:38,396 WARN  [io.qua.arc.impl] (main)
================================================================================
CDI: programmatic lookup problem detected
-----------------------------------------
At least one bean matched the required type and qualifiers but was marked as unused and removed during build

Stack frame: io.quarkus.resteasy.common.runtime.QuarkusConstructorInjector.construct(QuarkusConstructorInjector.java:35)
Required type: class io.quarkus.smallrye.opentracing.runtime.QuarkusSmallRyeTracingDynamicFeature
Required qualifiers: [@javax.enterprise.inject.Default()]
Removed beans:
	- CLASS bean  [types=[class io.quarkus.smallrye.opentracing.runtime.QuarkusSmallRyeTracingDynamicFeature, interface javax.ws.rs.container.DynamicFeature], qualifiers=null]
Solutions:
	- Application developers can eliminate false positives via the @Unremovable annotation
	- Extensions can eliminate false positives via build items, e.g. using the UnremovableBeanBuildItem
	- See also https://quarkus.io/guides/cdi-reference#remove_unused_beans
	- Enable the DEBUG log level to see the full stack trace
================================================================================

2022-01-04 09:55:38,449 INFO  [io.quarkus] (main) Quarkus 2.6.1.Final on JVM started in 1.081s.
2022-01-04 09:55:38,449 INFO  [io.quarkus] (main) Profile test activated.
2022-01-04 09:55:38,450 INFO  [io.quarkus] (main) Installed features: [cdi, jaeger, rest-client, rest-client-jackson, smallrye-opentracing]
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 2.76 s <<< FAILURE! - in io.quarkus.qe.MyRemoteServiceTest
[ERROR] io.quarkus.qe.MyRemoteServiceTest.testExtensionsRestClientEndpoint  Time elapsed: 0.004 s  <<< ERROR!
org.junit.jupiter.api.extension.TestInstantiationException: Failed to create test instance
Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
Caused by: java.lang.reflect.InvocationTargetException
Caused by: java.lang.RuntimeException: Error injecting io.quarkus.qe.MyRemoteService io.quarkus.qe.MyRemoteServiceTest.myRemoteService
Caused by: java.lang.NullPointerException

2022-01-04 09:55:38,652 INFO  [io.quarkus] (main) Quarkus stopped in 0.008s
[INFO]
[INFO] Results:
[INFO]
[ERROR] Errors:
[ERROR]   MyRemoteServiceTest.testExtensionsRestClientEndpoint » TestInstantiation Faile...
[INFO]
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0

Expected behavior

mvn clean verify passes

Actual behavior

mvn clean verify execution fails with NPE

How to Reproduce?

Generate the project:

  • mvn -Dquarkus.platform.artifact-id=quarkus-bom io.quarkus:quarkus-maven-plugin:2.6.1.Final:create -DprojectGroupId=io.quarkus.qe -DprojectArtifactId=rest-client-smallrye-opentracing -DprojectVersion=1.0.0-SNAPSHOT -DplatformGroupId=io.quarkus -DplatformArtifactId=quarkus-bom -Dextensions=rest-client,smallrye-opentracing

Run it:

  • mvn clean verify -f rest-client-smallrye-opentracing

Output of uname -a or ver

No response

Output of java -version

Java 17

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.6.1.Final

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

No response

Additional information

No response

@quarkus-bot
Copy link

quarkus-bot bot commented Jan 4, 2022

@geoand
Copy link
Contributor

geoand commented Jan 4, 2022

I will take a look at this as @metacosm brought this to my attention via quarkiverse/quarkus-operator-sdk#174 which seems to share the same root cause

@geoand geoand self-assigned this Jan 4, 2022
geoand added a commit to geoand/quarkus that referenced this issue Jan 4, 2022
This is needed because without this change, applications that only
include the rest-client without including the server component,
result in the providers not being registered as unremovable beans.

Fixes: quarkusio#22605
geoand added a commit that referenced this issue Jan 5, 2022
Move RESTEasy provider registration as unremovable beans to common module
@quarkus-bot quarkus-bot bot added this to the 2.7 - main milestone Jan 5, 2022
@gsmet gsmet modified the milestones: 2.7 - main, 2.6.2.Final Jan 7, 2022
gsmet pushed a commit to gsmet/quarkus that referenced this issue Jan 7, 2022
This is needed because without this change, applications that only
include the rest-client without including the server component,
result in the providers not being registered as unremovable beans.

Fixes: quarkusio#22605
(cherry picked from commit 1384373)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants