Skip to content

Commit

Permalink
Avoid potential NPE when collecting RESTEasy Providers on Resource cl…
Browse files Browse the repository at this point in the history
…asses

Addresses: quarkusio#14418 (comment)
(cherry picked from commit e104aa1)
  • Loading branch information
geoand authored and gsmet committed Jan 19, 2022
1 parent 43ac218 commit 1202718
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -531,8 +531,10 @@ private static boolean collectDeclaredProvidersForMethodAndMediaTypeAnnotation(S
AnnotationInstance mediaTypeClassAnnotationInstance = methodTarget.declaringClass()
.classAnnotation(mediaTypeAnnotation);
if (mediaTypeClassAnnotationInstance != null) {
if (collectDeclaredProvidersForMediaTypeAnnotationInstance(providersToRegister, categorizedProviders,
mediaTypeClassAnnotationInstance.value().asStringArray(), methodTarget)) {
AnnotationValue mediaTypeClassValue = mediaTypeClassAnnotationInstance.value();
if ((mediaTypeClassValue != null)
&& collectDeclaredProvidersForMediaTypeAnnotationInstance(providersToRegister, categorizedProviders,
mediaTypeClassValue.asStringArray(), methodTarget)) {
return true;
}
return false;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package io.quarkus.resteasy.test;

import static io.restassured.RestAssured.given;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Response;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import io.quarkus.test.QuarkusUnitTest;

public class NoProducesValueTest {

@RegisterExtension
static QuarkusUnitTest runner = new QuarkusUnitTest()
.withApplicationRoot((jar) -> jar
.addClasses(TestResource.class));

@Test
public void testSomething() {
given().when().get("/test/hello")
.then().statusCode(200);
}

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

@GET
@Path("hello")
public Response getHello() {
return Response.ok().build();
}
}
}

0 comments on commit 1202718

Please sign in to comment.