Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow loading custom Groovy extension modules #34447

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions core/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,6 @@
<parentFirstArtifact>io.quarkus:quarkus-bootstrap-gradle-resolver</parentFirstArtifact>
<parentFirstArtifact>io.quarkus:quarkus-junit5-mockito-config</parentFirstArtifact>

<!-- RestAssured uses groovy, which seems to do some things with soft references that
prevent the ClassLoader from being GC'ed, see https://github.com/quarkusio/quarkus/issues/12498 -->
<parentFirstArtifact>org.apache.groovy:groovy</parentFirstArtifact>

<!-- Load the junit engine parent first, so it is shared between the outer dev mode
process and the test application-->
<parentFirstArtifact>org.junit.platform:junit-platform-launcher</parentFirstArtifact>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package io.quarkus.test.common;

/**
* {@link ClassValue} are used in Groovy which causes memory leaks if not properly cleaned, but unfortunately, they are
* very complex to clean up, especially the {@link ClassValue} corresponding to system classes that must be cleaned too
* to avoid memory leaks moreover if not cleaned wisely errors of type {@code MissingMethodException} can be thrown, so
* we had better to simply disable them by setting the System property {@code groovy.use.classvalue} to {@code false}
* see <a href="https://issues.apache.org/jira/browse/GROOVY-7591">GROOVY-7591</a> for more details.
*/
public final class GroovyClassValue {

private GroovyClassValue() {
}

public static void disable() {
System.setProperty("groovy.use.classvalue", "false");
geoand marked this conversation as resolved.
Show resolved Hide resolved
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
import io.quarkus.paths.PathList;
import io.quarkus.runtime.LaunchMode;
import io.quarkus.runtime.configuration.ProfileManager;
import io.quarkus.test.common.GroovyCacheCleaner;
import io.quarkus.test.common.GroovyClassValue;
import io.quarkus.test.common.PathTestHelper;
import io.quarkus.test.common.PropertyTestUtil;
import io.quarkus.test.common.TestResourceManager;
Expand Down Expand Up @@ -219,6 +219,7 @@ public Object createTestInstance(TestInstanceFactoryContext factoryContext, Exte

@Override
public void beforeAll(ExtensionContext context) throws Exception {
GroovyClassValue.disable();
//set the right launch mode in the outer CL, used by the HTTP host config source
ProfileManager.setLaunchMode(LaunchMode.DEVELOPMENT);
originalRootLoggerHandlers = rootLogger.getHandlers();
Expand Down Expand Up @@ -313,7 +314,6 @@ public void afterAll(ExtensionContext context) throws Exception {
inMemoryLogHandler.clearRecords();
inMemoryLogHandler.setFilter(null);
ClearCache.clearAnnotationCache();
GroovyCacheCleaner.clearGroovyCache();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
import io.quarkus.runtime.LaunchMode;
import io.quarkus.runtime.configuration.ProfileManager;
import io.quarkus.runtime.logging.JBossVersion;
import io.quarkus.test.common.GroovyCacheCleaner;
import io.quarkus.test.common.GroovyClassValue;
import io.quarkus.test.common.PathTestHelper;
import io.quarkus.test.common.PropertyTestUtil;
import io.quarkus.test.common.RestAssuredURLManager;
Expand Down Expand Up @@ -506,6 +506,7 @@ private void runExtensionMethod(ReflectiveInvocationContext<Method> invocationCo

@Override
public void beforeAll(ExtensionContext extensionContext) throws Exception {
GroovyClassValue.disable();
//set the right launch mode in the outer CL, used by the HTTP host config source
ProfileManager.setLaunchMode(LaunchMode.TEST);
if (beforeAllCustomizer != null) {
Expand Down Expand Up @@ -759,7 +760,6 @@ public void afterAll(ExtensionContext extensionContext) throws Exception {
afterAllCustomizer.run();
}
ClearCache.clearAnnotationCache();
GroovyCacheCleaner.clearGroovyCache();
}
if (records != null) {
assertLogRecords.accept(records);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
import io.quarkus.runtime.logging.JBossVersion;
import io.quarkus.runtime.test.TestHttpEndpointProvider;
import io.quarkus.test.TestMethodInvoker;
import io.quarkus.test.common.GroovyCacheCleaner;
import io.quarkus.test.common.GroovyClassValue;
import io.quarkus.test.common.PathTestHelper;
import io.quarkus.test.common.PropertyTestUtil;
import io.quarkus.test.common.RestAssuredURLManager;
Expand Down Expand Up @@ -296,7 +296,6 @@ public void close() throws IOException {
tm.close();
} finally {
restorableSystemProperties.close();
GroovyCacheCleaner.clearGroovyCache();
shutdownHangDetection();
}
}
Expand Down Expand Up @@ -645,6 +644,7 @@ private void throwBootFailureException() {

@Override
public void beforeAll(ExtensionContext context) throws Exception {
GroovyClassValue.disable();
currentTestClassStack.push(context.getRequiredTestClass());
//set the right launch mode in the outer CL, used by the HTTP host config source
ProfileManager.setLaunchMode(LaunchMode.TEST);
Expand Down