Skip to content

Commit

Permalink
Ensure that duplicate endpoints don't prevent hot-reload
Browse files Browse the repository at this point in the history
Fixes: #35355
  • Loading branch information
geoand committed Aug 21, 2023
1 parent 17804c8 commit 3c31743
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

import jakarta.enterprise.inject.spi.DeploymentException;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.Priorities;
import jakarta.ws.rs.Produces;
Expand Down Expand Up @@ -194,7 +195,6 @@
import io.quarkus.resteasy.reactive.spi.MessageBodyWriterOverrideBuildItem;
import io.quarkus.runtime.LaunchMode;
import io.quarkus.runtime.RuntimeValue;
import io.quarkus.runtime.configuration.ConfigurationException;
import io.quarkus.security.AuthenticationCompletionException;
import io.quarkus.security.AuthenticationFailedException;
import io.quarkus.security.AuthenticationRedirectException;
Expand Down Expand Up @@ -1356,7 +1356,7 @@ private void checkForDuplicateEndpoint(ResteasyReactiveConfig config, Map<String
.collect(Collectors.joining());
if (message.length() > 0) {
if (config.failOnDuplicate()) {
throw new ConfigurationException(message);
throw new DeploymentException(message);
}
log.warn(message);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package io.quarkus.resteasy.reactive.server.test.duplicate;

import static io.restassured.RestAssured.when;

import java.util.function.Function;

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.QuarkusDevModeTest;

public class DuplicateResourceDetectionDevModeTest {

@RegisterExtension
static QuarkusDevModeTest TEST = new QuarkusDevModeTest()
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class)
.addClasses(GreetingResource3.class, GreetingResource4.class))
.setAllowFailedStart(true);

@Test
public void testRestarts() {
// The build should fail initially
when()
.get("/hello-resteasy")
.then()
.statusCode(500);

TEST.modifySourceFile(GreetingResource4.class.getSimpleName() + ".java", new Function<>() {
@Override
public String apply(String s) {
return s.replace("hello-resteasy", "hello-resteasy2");
}
});

// after changing the paths to remove the collision, the endpoints should work
when()
.get("/hello-resteasy")
.then()
.statusCode(200);
when()
.get("/hello-resteasy2")
.then()
.statusCode(200);

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

import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;

@Path("/hello-resteasy")
public class GreetingResource4 {

@GET
@Consumes(MediaType.APPLICATION_ATOM_XML)
public String helloGet(String tutu) {
return "Hello get";
}

@POST
@Produces(MediaType.TEXT_PLAIN)
public String helloPost(String yo) {
return "Hello post";
}
}

0 comments on commit 3c31743

Please sign in to comment.