diff --git a/extensions/smallrye-graphql/runtime/src/main/java/io/quarkus/smallrye/graphql/runtime/SmallRyeGraphQLRecorder.java b/extensions/smallrye-graphql/runtime/src/main/java/io/quarkus/smallrye/graphql/runtime/SmallRyeGraphQLRecorder.java index 111bb4fae199c..a993ba90ad40f 100644 --- a/extensions/smallrye-graphql/runtime/src/main/java/io/quarkus/smallrye/graphql/runtime/SmallRyeGraphQLRecorder.java +++ b/extensions/smallrye-graphql/runtime/src/main/java/io/quarkus/smallrye/graphql/runtime/SmallRyeGraphQLRecorder.java @@ -1,7 +1,5 @@ package io.quarkus.smallrye.graphql.runtime; -import java.util.function.Supplier; - import javax.enterprise.inject.Instance; import javax.enterprise.inject.spi.CDI; @@ -10,7 +8,6 @@ import io.quarkus.runtime.annotations.Recorder; import io.quarkus.security.identity.CurrentIdentityAssociation; import io.quarkus.smallrye.graphql.runtime.spi.QuarkusClassloadingService; -import io.quarkus.vertx.http.runtime.ThreadLocalHandler; import io.smallrye.graphql.cdi.producer.GraphQLProducer; import io.smallrye.graphql.schema.model.Schema; import io.vertx.core.Handler; @@ -45,14 +42,9 @@ public Handler schemaHandler() { public Handler uiHandler(String graphqlUiFinalDestination, String graphqlUiPath) { - Handler handler = new ThreadLocalHandler(new Supplier>() { - @Override - public Handler get() { - return StaticHandler.create().setAllowRootFileSystemAccess(true) - .setWebRoot(graphqlUiFinalDestination) - .setDefaultContentEncoding("UTF-8"); - } - }); + StaticHandler staticHandler = StaticHandler.create().setAllowRootFileSystemAccess(true) + .setWebRoot(graphqlUiFinalDestination) + .setDefaultContentEncoding("UTF-8"); return new Handler() { @Override @@ -68,7 +60,7 @@ public void handle(RoutingContext event) { return; } - handler.handle(event); + staticHandler.handle(event); } }; } diff --git a/extensions/smallrye-health/runtime/src/main/java/io/quarkus/smallrye/health/runtime/SmallRyeHealthRecorder.java b/extensions/smallrye-health/runtime/src/main/java/io/quarkus/smallrye/health/runtime/SmallRyeHealthRecorder.java index f018d407488c8..ef24518be6bf0 100644 --- a/extensions/smallrye-health/runtime/src/main/java/io/quarkus/smallrye/health/runtime/SmallRyeHealthRecorder.java +++ b/extensions/smallrye-health/runtime/src/main/java/io/quarkus/smallrye/health/runtime/SmallRyeHealthRecorder.java @@ -1,12 +1,9 @@ package io.quarkus.smallrye.health.runtime; -import java.util.function.Supplier; - import org.eclipse.microprofile.health.HealthCheckResponse; import org.eclipse.microprofile.health.spi.HealthCheckResponseProvider; import io.quarkus.runtime.annotations.Recorder; -import io.quarkus.vertx.http.runtime.ThreadLocalHandler; import io.vertx.core.Handler; import io.vertx.core.http.HttpHeaders; import io.vertx.ext.web.RoutingContext; @@ -26,14 +23,9 @@ public void registerHealthCheckResponseProvider(Class uiHandler(String healthUiFinalDestination, String healthUiPath) { - Handler handler = new ThreadLocalHandler(new Supplier>() { - @Override - public Handler get() { - return StaticHandler.create().setAllowRootFileSystemAccess(true) - .setWebRoot(healthUiFinalDestination) - .setDefaultContentEncoding("UTF-8"); - } - }); + StaticHandler staticHandler = StaticHandler.create().setAllowRootFileSystemAccess(true) + .setWebRoot(healthUiFinalDestination) + .setDefaultContentEncoding("UTF-8"); return new Handler() { @Override @@ -49,7 +41,7 @@ public void handle(RoutingContext event) { return; } - handler.handle(event); + staticHandler.handle(event); } }; } diff --git a/extensions/swagger-ui/runtime/src/main/java/io/quarkus/swaggerui/runtime/SwaggerUiRecorder.java b/extensions/swagger-ui/runtime/src/main/java/io/quarkus/swaggerui/runtime/SwaggerUiRecorder.java index c59d3ee98cbed..745e8122f276b 100644 --- a/extensions/swagger-ui/runtime/src/main/java/io/quarkus/swaggerui/runtime/SwaggerUiRecorder.java +++ b/extensions/swagger-ui/runtime/src/main/java/io/quarkus/swaggerui/runtime/SwaggerUiRecorder.java @@ -1,9 +1,6 @@ package io.quarkus.swaggerui.runtime; -import java.util.function.Supplier; - import io.quarkus.runtime.annotations.Recorder; -import io.quarkus.vertx.http.runtime.ThreadLocalHandler; import io.vertx.core.Handler; import io.vertx.core.http.HttpHeaders; import io.vertx.ext.web.RoutingContext; @@ -13,14 +10,9 @@ public class SwaggerUiRecorder { public Handler handler(String swaggerUiFinalDestination, String swaggerUiPath) { - Handler handler = new ThreadLocalHandler(new Supplier>() { - @Override - public Handler get() { - return StaticHandler.create().setAllowRootFileSystemAccess(true) - .setWebRoot(swaggerUiFinalDestination) - .setDefaultContentEncoding("UTF-8"); - } - }); + StaticHandler staticHandler = StaticHandler.create().setAllowRootFileSystemAccess(true) + .setWebRoot(swaggerUiFinalDestination) + .setDefaultContentEncoding("UTF-8"); return new Handler() { @Override @@ -36,7 +28,7 @@ public void handle(RoutingContext event) { return; } - handler.handle(event); + staticHandler.handle(event); } }; } diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/StaticResourcesRecorder.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/StaticResourcesRecorder.java index 36b435df3f2b4..9fb213e27e2ad 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/StaticResourcesRecorder.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/StaticResourcesRecorder.java @@ -5,7 +5,6 @@ import java.util.List; import java.util.Set; import java.util.function.Consumer; -import java.util.function.Supplier; import io.quarkus.runtime.annotations.Recorder; import io.vertx.core.Handler; @@ -36,17 +35,11 @@ public Consumer start() { if (hotDeploymentResourcePaths != null && !hotDeploymentResourcePaths.isEmpty()) { for (Path resourcePath : hotDeploymentResourcePaths) { String root = resourcePath.toAbsolutePath().toString(); - ThreadLocalHandler staticHandler = new ThreadLocalHandler(new Supplier>() { - @Override - public Handler get() { - StaticHandler staticHandler = StaticHandler.create(); - staticHandler.setCachingEnabled(false); - staticHandler.setAllowRootFileSystemAccess(true); - staticHandler.setWebRoot(root); - staticHandler.setDefaultContentEncoding("UTF-8"); - return staticHandler; - } - }); + StaticHandler staticHandler = StaticHandler.create(); + staticHandler.setCachingEnabled(false); + staticHandler.setAllowRootFileSystemAccess(true); + staticHandler.setWebRoot(root); + staticHandler.setDefaultContentEncoding("UTF-8"); handlers.add(event -> { try { staticHandler.handle(event); @@ -59,13 +52,7 @@ public Handler get() { } } if (!knownPaths.isEmpty()) { - ThreadLocalHandler staticHandler = new ThreadLocalHandler(new Supplier>() { - @Override - public Handler get() { - return StaticHandler.create(META_INF_RESOURCES) - .setDefaultContentEncoding("UTF-8"); - } - }); + StaticHandler staticHandler = StaticHandler.create(META_INF_RESOURCES).setDefaultContentEncoding("UTF-8"); handlers.add(ctx -> { String rel = ctx.mountPoint() == null ? ctx.normalisedPath() : ctx.normalisedPath().substring(ctx.mountPoint().length()); diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/ThreadLocalHandler.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/ThreadLocalHandler.java deleted file mode 100644 index e3be0dede558c..0000000000000 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/ThreadLocalHandler.java +++ /dev/null @@ -1,25 +0,0 @@ -package io.quarkus.vertx.http.runtime; - -import java.util.function.Supplier; - -import io.vertx.core.Handler; -import io.vertx.ext.web.RoutingContext; - -public class ThreadLocalHandler implements Handler { - - private final ThreadLocal> threadLocal; - - public ThreadLocalHandler(Supplier> supplier) { - threadLocal = new ThreadLocal>() { - @Override - protected Handler initialValue() { - return supplier.get(); - } - }; - } - - @Override - public void handle(RoutingContext event) { - threadLocal.get().handle(event); - } -} diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/VertxHttpRecorder.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/VertxHttpRecorder.java index a240b7ec37f26..5a39a7b39d5e4 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/VertxHttpRecorder.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/VertxHttpRecorder.java @@ -105,7 +105,7 @@ public class VertxHttpRecorder { public static final String MAX_REQUEST_SIZE_KEY = "io.quarkus.max-request-size"; - // We don not use Integer.MAX on purpose to allow advanced users to register a route AFTER the default route + // We do not use Integer.MAX on purpose to allow advanced users to register a route AFTER the default route public static final int DEFAULT_ROUTE_ORDER = 10_000; private static final Logger LOGGER = Logger.getLogger(VertxHttpRecorder.class.getName());