Skip to content

Commit

Permalink
Provide actionable error message when non-static inner class used as …
Browse files Browse the repository at this point in the history
…JAX-RS resource

Closes: quarkusio#19757
  • Loading branch information
geoand committed Aug 30, 2021
1 parent 45511d9 commit 55daca5
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package io.quarkus.resteasy.reactive.server.test;

import static org.junit.jupiter.api.Assertions.fail;

import java.util.function.Supplier;

import javax.enterprise.inject.spi.DeploymentException;
import javax.ws.rs.Path;

import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import io.quarkus.test.QuarkusUnitTest;
import io.smallrye.common.annotation.Blocking;

public class InnerClassTest {

@RegisterExtension
static QuarkusUnitTest test = new QuarkusUnitTest()
.setArchiveProducer(new Supplier<>() {
@Override
public JavaArchive get() {
return ShrinkWrap.create(JavaArchive.class)
.addClasses(Resource.class);
}
}).setExpectedException(DeploymentException.class);

@Test
public void test() {
fail("Should never have been called");
}

@Path("test")
public class Resource {

@Path("hello")
@Blocking
public String hello() {
return "hello";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,10 @@ public ResourceClass createEndpoints(ClassInfo classInfo) {
try {
String path = scannedResourcePaths.get(classInfo.name());
ResourceClass clazz = new ResourceClass();
if ((classInfo.enclosingClass() != null) && !Modifier.isStatic(classInfo.flags())) {
throw new DeploymentException(
"Non static nested resources classes are not supported: '" + classInfo.name() + "'");
}
clazz.setClassName(classInfo.name().toString());
if (path != null) {
if (path.endsWith("/")) {
Expand Down

0 comments on commit 55daca5

Please sign in to comment.