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

ResteasyCommonProcessor: NullPointerException in case of using default annotation values for @Produces or @Consumes #14418

Closed
HardNorth opened this issue Jan 20, 2021 · 5 comments · Fixed by #14420
Assignees
Labels
area/resteasy-classic kind/bug Something isn't working
Milestone

Comments

@HardNorth
Copy link
Contributor

Describe 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:

  1. 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 :)
image

Environment (please complete the following information):

  • Output of uname -a or ver: 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 or gradlew --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.

@HardNorth HardNorth added the kind/bug Something isn't working label Jan 20, 2021
@ghost ghost added the env/windows Impacts Windows machines label Jan 20, 2021
@geoand geoand self-assigned this Jan 20, 2021
@geoand geoand added area/resteasy-classic and removed env/windows Impacts Windows machines labels Jan 20, 2021
geoand added a commit to geoand/quarkus that referenced this issue Jan 20, 2021
geoand added a commit to geoand/quarkus that referenced this issue Jan 20, 2021
geoand added a commit to geoand/quarkus that referenced this issue Jan 20, 2021
gsmet added a commit that referenced this issue Jan 20, 2021
Avoid potential NPE when collecting RESTEasy Providers on Resource methods
@ghost ghost added this to the 1.12 - master milestone Jan 20, 2021
@gsmet gsmet modified the milestones: 1.12 - master, 1.11.1.Final Jan 21, 2021
gsmet pushed a commit to gsmet/quarkus that referenced this issue Jan 21, 2021
@khoek
Copy link

khoek commented Jan 19, 2022

@geoand I can still reproduce this when annotating a resource class, e.g.

    @Produces
    @Path("__test")
    public static class TestResource {

        @GET
        @Path("testing")
        public Response getTest() {
            return Response.ok().build();
        }
    }

@geoand
Copy link
Contributor

geoand commented Jan 19, 2022

What version are you seeing the problem with?

@khoek
Copy link

khoek commented Jan 19, 2022

@geoand 2.6.1.Final, here is a reproducer: https://github.com/khoek/quarkus-bug

@khoek
Copy link

khoek commented Jan 19, 2022

To be clear, you totally fixed it for @Produces on resource methods themselves.

@geoand
Copy link
Contributor

geoand commented Jan 19, 2022

Thanks for the reproducer!

#23019 takes care of it

gsmet pushed a commit to gsmet/quarkus that referenced this issue Jan 19, 2022
geoand added a commit that referenced this issue Jan 20, 2022
Avoid potential NPE when collecting RESTEasy Providers on Resource classes
gsmet pushed a commit to gsmet/quarkus that referenced this issue Jan 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/resteasy-classic kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants