Skip to content

Commit

Permalink
Merge pull request quarkusio#41721 from michalvavrik/feature/fix-quar…
Browse files Browse the repository at this point in the history
…kus-rest-concurrent-modif-ex

Fix Quarkus REST concurrent modification exception when making abstract resource classes inheritors beans
  • Loading branch information
gsmet authored Jul 6, 2024
2 parents d7c8f08 + 2ba9f52 commit 5ab89e9
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import io.quarkus.resteasy.reactive.server.test.resource.basic.resource.InheritanceAbstractParentImplResource;
import io.quarkus.resteasy.reactive.server.test.resource.basic.resource.InheritanceAbstractParentResource;
import io.quarkus.resteasy.reactive.server.test.resource.basic.resource.InheritanceParentResource;
import io.quarkus.resteasy.reactive.server.test.resource.basic.resource.InheritanceParentResourceImpl;
import io.quarkus.resteasy.reactive.server.test.simple.PortProviderUtil;
Expand All @@ -39,6 +41,8 @@ public class InheritanceTest {
public JavaArchive get() {
JavaArchive war = ShrinkWrap.create(JavaArchive.class);
war.addClass(InheritanceParentResource.class);
war.addClass(InheritanceAbstractParentResource.class);
war.addClass(InheritanceAbstractParentImplResource.class);
war.addClasses(PortProviderUtil.class, InheritanceParentResourceImpl.class);
return war;
}
Expand Down Expand Up @@ -67,4 +71,13 @@ public void Test1() throws Exception {
Assertions.assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
Assertions.assertEquals(response.readEntity(String.class), "First");
}

@Test
public void testAbstractParent() {
Builder builder = client.target(generateURL("/inheritance-abstract-parent-test")).request();
builder.header("Accept", "text/plain");
Response response = builder.get();
Assertions.assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
Assertions.assertEquals(response.readEntity(String.class), "works");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package io.quarkus.resteasy.reactive.server.test.resource.basic.resource;

public class InheritanceAbstractParentImplResource extends InheritanceAbstractParentResource {

@Override
public String get() {
return "works";
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package io.quarkus.resteasy.reactive.server.test.resource.basic.resource;

import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;

@Path("/inheritance-abstract-parent-test")
public abstract class InheritanceAbstractParentResource {

@GET
public abstract String get();

}
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,8 @@ public static ResourceScanningResult scanResources(
}

// handle abstract classes
scannedResources.values().stream().filter(ClassInfo::isAbstract).forEach(abstractScannedResource -> {
var abstractClasses = scannedResources.values().stream().filter(ClassInfo::isAbstract).toList();
abstractClasses.forEach(abstractScannedResource -> {
Collection<ClassInfo> allSubclasses = index.getAllKnownSubclasses(abstractScannedResource.name());
if (allSubclasses.size() != 1) {
return; // don't do anything with this case as it's not evident how it's supposed to be handled
Expand Down

0 comments on commit 5ab89e9

Please sign in to comment.