Skip to content

Commit

Permalink
Merge pull request #16237 from geoand/#16228
Browse files Browse the repository at this point in the history
Fix JAX-RS Application class hierarchy handling
  • Loading branch information
gsmet authored Apr 6, 2021
2 parents 10cafbe + d06eddf commit 0da7627
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -953,6 +953,9 @@ private static Set<String> getAllowedClasses(IndexView index) {
Application application;
ClassInfo selectedAppClass = null;
for (ClassInfo applicationClassInfo : applications) {
if (Modifier.isAbstract(applicationClassInfo.flags())) {
continue;
}
if (selectedAppClass != null) {
throw new RuntimeException("More than one Application class: " + applications);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class ApplicationPathHttpRootTest {
@RegisterExtension
static QuarkusUnitTest runner = new QuarkusUnitTest()
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class)
.addClasses(HelloResource.class, HelloApp.class)
.addClasses(HelloResource.class, HelloApp.class, BaseApplication.class)
.addAsResource(new StringAsset("quarkus.http.root-path=/foo"), "application.properties"));

@Test
Expand All @@ -44,7 +44,11 @@ public String hello() {
}

@ApplicationPath("hello")
public static class HelloApp extends Application {
public static class HelloApp extends BaseApplication {

}

public static abstract class BaseApplication extends Application {

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class RestApplicationPathTestCase {
.overrideConfigKey("quarkus.rest.path", "/foo")
.overrideConfigKey("quarkus.http.root-path", "/app")
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class)
.addClasses(HelloResource.class, BarApp.class));
.addClasses(HelloResource.class, BarApp.class, BaseApplication.class));

/**
* Using @ApplicationPath will overlay/replace `quarkus.rest.path`.
Expand All @@ -33,7 +33,10 @@ public class RestApplicationPathTestCase {
* This path will also be relative to the configured HTTP root
*/
@ApplicationPath("/bar")
public static class BarApp extends Application {
public static class BarApp extends BaseApplication {
}

public static abstract class BaseApplication extends Application {
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ public static ApplicationScanningResult scanForApplicationClass(IndexView index,
ClassInfo selectedAppClass = null;
boolean blocking = false;
for (ClassInfo applicationClassInfo : applications) {
if (Modifier.isAbstract(applicationClassInfo.flags())) {
continue;
}
if (selectedAppClass != null) {
throw new RuntimeException("More than one Application class: " + applications);
}
Expand Down

0 comments on commit 0da7627

Please sign in to comment.