From d30d070b1132a2975bb1eac327f13e7445c0670b Mon Sep 17 00:00:00 2001 From: Georgios Andrianakis Date: Tue, 6 Aug 2024 14:11:24 +0300 Subject: [PATCH] Fix ClassLoader leak in KeycloakDevServicesProcessor Fixes: #42303 --- .../keycloak/KeycloakDevServicesProcessor.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/extensions/oidc/deployment/src/main/java/io/quarkus/oidc/deployment/devservices/keycloak/KeycloakDevServicesProcessor.java b/extensions/oidc/deployment/src/main/java/io/quarkus/oidc/deployment/devservices/keycloak/KeycloakDevServicesProcessor.java index cb54e61efe09d..9086c453f4e27 100644 --- a/extensions/oidc/deployment/src/main/java/io/quarkus/oidc/deployment/devservices/keycloak/KeycloakDevServicesProcessor.java +++ b/extensions/oidc/deployment/src/main/java/io/quarkus/oidc/deployment/devservices/keycloak/KeycloakDevServicesProcessor.java @@ -189,9 +189,6 @@ public DevServicesResultBuildItem startKeycloakContainer( StartupLogCompressor compressor = new StartupLogCompressor( (launchMode.isTest() ? "(test) " : "") + "Keycloak Dev Services Starting:", consoleInstalledBuildItem, loggingSetupBuildItem); - if (vertxInstance == null) { - vertxInstance = Vertx.vertx(); - } try { List errors = new ArrayList<>(); @@ -281,6 +278,12 @@ private Map prepareConfiguration( List realmNames = new LinkedList<>(); + // this needs to be only if we actually start the dev-service as it adds a shutdown hook + // whose TCCL is the Augmentation CL, which if not removed, causes a massive memory leaks + if (vertxInstance == null) { + vertxInstance = Vertx.vertx(); + } + WebClient client = OidcDevServicesUtils.createWebClient(vertxInstance); try { String adminToken = getAdminToken(client, clientAuthServerBaseUrl);