ResteasyCommonProcessor: NullPointerException in case of using default annotation values for `@Produces` or `@Consumes`
See original GitHub issueDescribe the bug
Hello. I’m getting a NullPointerException
if I try to run a test for a simple web service with @Produces
or @Consumes
annotations default values.
Here is an example of such method:
@POST
@Path("integration")
@Consumes
@Produces
public Response createIntegration() {
return WebServiceCommon.performRedirect(authService.createIntegration());
}
And the class itself: https://github.com/HardNorth/service-merge-validate/blob/c8952c753a693f287ce9655a8e55f34af4ea72d3/src/main/java/net/hardnorth/github/merge/api/MergeValidateController.java
Expected behavior No exception. A test passes.
Actual behavior
java.lang.RuntimeException: java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
[error]: Build step io.quarkus.resteasy.common.deployment.ResteasyCommonProcessor#setupProviders threw an exception: java.lang.NullPointerException
at io.quarkus.resteasy.common.deployment.ResteasyCommonProcessor.collectDeclaredProvidersForMethodAndMediaTypeAnnotation(ResteasyCommonProcessor.java:531)
at io.quarkus.resteasy.common.deployment.ResteasyCommonProcessor.collectDeclaredProviders(ResteasyCommonProcessor.java:463)
at io.quarkus.resteasy.common.deployment.ResteasyCommonProcessor.setupProviders(ResteasyCommonProcessor.java:222)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:972)
at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2415)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1452)
at java.base/java.lang.Thread.run(Thread.java:834)
at org.jboss.threads.JBossThread.run(JBossThread.java:501)
To Reproduce
It will be enough to write a test on the following method:
@POST
@Path("test")
@Consumes
@Produces
public Response test() {
return Response.status(200).entity("OK").build();
}
The test:
@QuarkusTest
public class EndpointTest{
@Test
public void tesEndpoint() {
given()
.when().post("/test")
.then()
.statusCode(200)
.body(is("OK"));
}
}
Steps to reproduce the behavior:
- Just run the test above
Configuration Here is my pom.xml file: https://github.com/HardNorth/service-merge-validate/blob/620c7ab336081db67cf6eab89c976f626ec67516/pom.xml
I’m using quarkus version 1.11.0.Final
, the latest one on the moment I created the bug.
Screenshots
Well, OK 😃
Environment (please complete the following information):
- Output of
uname -a
orver
: Microsoft Windows 10 Home - 10.0.19042 N/A Build 19042 - Output of
java -version
: openjdk 11 2018-09-25 OpenJDK Runtime Environment 18.9 (build 11+28) OpenJDK 64-Bit Server VM 18.9 (build 11+28, mixed mode) - Quarkus version or git rev: 1.11.0.Final
- Build tool (ie. output of
mvnw --version
orgradlew --version
): Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f) Maven home: C:\Users\delgr.m2\wrapper\dists\apache-maven-3.6.3-bin\1iopthnavndlasol9gbrbg6bf2\apache-maven-3.6.3 Java version: 11, vendor: Oracle Corporation, runtime: c:\java\openjdk_11 Default locale: en_US, platform encoding: Cp1251 OS name: “windows 10”, version: “10.0”, arch: “amd64”, family: “windows”
Additional context
Well, as far as I digged into the problem the most probable culprit is jandex
since it looks like it returns an instance of AnnotationInstance
class with null
in AnnotationValue
field. That’s definetely incorrect since Annotations can’t have null fields. But I do not have all the details how quarkus uses jandex
to post a bug on it, so please re-route the issue if I’m right here.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)
Thanks for the reproducer!
https://github.com/quarkusio/quarkus/pull/23019 takes care of it
To be clear, you totally fixed it for
@Produces
on resource methods themselves.