Skip to content

Commit

Permalink
Make sure request resumes on correct thread
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartwdouglas committed Jun 23, 2020
1 parent c675daa commit e2eeff9
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,6 @@ public RuntimeValue<Router> initializeRouter(final Supplier<Vertx> vertxRuntimeV

Vertx vertx = vertxRuntimeValue.get();
Router router = Router.router(vertx);
if (hotReplacementHandler != null) {
router.route().order(Integer.MIN_VALUE).handler(hotReplacementHandler);
}

return new RuntimeValue<>(router);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import io.vertx.core.Handler;
import io.vertx.core.Promise;
import io.vertx.core.http.HttpServerResponse;
import io.vertx.core.net.impl.ConnectionBase;
import io.vertx.ext.web.RoutingContext;

public class VertxHttpHotReplacementSetup implements HotReplacementSetup {
Expand Down Expand Up @@ -39,7 +40,8 @@ void handleHotReplacementRequest(RoutingContext routingContext) {
routingContext.next();
return;
}
routingContext.vertx().executeBlocking(new Handler<Promise<Boolean>>() {
ConnectionBase connectionBase = (ConnectionBase) routingContext.request().connection();
connectionBase.getContext().executeBlocking(new Handler<Promise<Boolean>>() {
@Override
public void handle(Promise<Boolean> event) {
boolean restart = false;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package io.quarkus.vertx.web;

import java.util.function.Function;

import org.hamcrest.Matchers;
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;
import io.restassured.RestAssured;

public class VertxWebDevModeTestCase {

@RegisterExtension
static QuarkusDevModeTest runner = new QuarkusDevModeTest()
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class)
.addClasses(TestRoute.class));

@Test
public void testRunningInDevMode() {
RestAssured.given()
.body("OK")
.post("/test")
.then().statusCode(200)
.body(Matchers.equalTo("test route"));

runner.modifySourceFile(TestRoute.class, new Function<String, String>() {
@Override
public String apply(String s) {
return s.replace("test route", "new code");
}
});
for (int i = 0; i < 10; ++i) {
RestAssured.given()
.body("OK")
.post("/test")
.then().statusCode(200)
.body(Matchers.equalTo("new code"));
}
}

}

0 comments on commit e2eeff9

Please sign in to comment.