Fixing classloading issue due to the curated application being eagerly closed

This commit is contained in:
Pedro Igor 2023-03-10 18:52:57 -03:00 committed by Václav Muzikář
parent f5ebe675a8
commit af475ffe23
3 changed files with 12 additions and 12 deletions

View file

@ -64,7 +64,6 @@ public class Keycloak {
System.setProperty("quarkus.http.test-ssl-port", "${kc.https-port}");
}
public static void main(String[] args) {
Keycloak.builder().start(args);
}
@ -187,6 +186,7 @@ public class Keycloak {
return new Builder();
}
private CuratedApplication curated;
private RunningQuarkusApplication application;
private ApplicationModel applicationModel;
private Path homeDir;
@ -214,9 +214,11 @@ public class Keycloak {
.setApplicationRoot(applicationModel.getApplicationModule().getModuleDir().toPath())
.setTargetDirectory(applicationModel.getApplicationModule().getModuleDir().toPath())
.setIsolateDeployment(true)
.setFlatClassPath(true)
.setMode(QuarkusBootstrap.Mode.TEST);
try (CuratedApplication curated = builder.build().bootstrap()) {
try {
curated = builder.build().bootstrap();
AugmentAction action = curated.createAugmentor();
Environment.setHomeDir(homeDir);
ConfigArgsConfigSource.setCliArgs(args.toArray(new String[0]));
@ -309,14 +311,11 @@ public class Keycloak {
private void closeApplication() {
if (application != null) {
ClassLoader old = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(application.getClassLoader());
try {
// curated application is also closed
application.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
Thread.currentThread().setContextClassLoader(old);
} catch (Exception cause) {
cause.printStackTrace();
}
}
@ -334,5 +333,6 @@ public class Keycloak {
}
application = null;
curated = null;
}
}

View file

@ -1137,10 +1137,10 @@
<profile>
<id>auth-server-quarkus-embedded</id>
<properties>
<surefire.memory.Xms>1024m</surefire.memory.Xms>
<surefire.memory.Xmx>1024m</surefire.memory.Xmx>
<surefire.memory.Xms>2048m</surefire.memory.Xms>
<surefire.memory.Xmx>2048m</surefire.memory.Xmx>
<surefire.memory.metaspace>512m</surefire.memory.metaspace>
<surefire.memory.metaspace.max>512m</surefire.memory.metaspace.max>
<surefire.memory.metaspace.max>1024m</surefire.memory.metaspace.max>
</properties>
<dependencies>
<dependency>

View file

@ -42,7 +42,7 @@ public class KeycloakQuarkusEmbeddedDeployableContainer extends AbstractQuarkusD
.setHomeDir(configuration.getProvidersPath())
.setVersion(KEYCLOAK_VERSION)
.addDependency("org.keycloak.testsuite", "integration-arquillian-testsuite-providers", KEYCLOAK_VERSION)
.addDependency("org.keycloak.testsuite", "integration-arquillian-testsuite-providers", KEYCLOAK_VERSION)
.addDependency("org.keycloak.testsuite", "integration-arquillian-testsuite-providers-deployment", KEYCLOAK_VERSION)
.addDependency("org.keycloak.testsuite", "integration-arquillian-tests-base", KEYCLOAK_VERSION)
.addDependency("org.keycloak.testsuite", "integration-arquillian-tests-base", KEYCLOAK_VERSION, "tests");
}