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

Avoid potential NPE when collecting RESTEasy Providers on Resource classes #23019

Merged
merged 1 commit into from
Jan 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
}
}
}