diff --git a/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/TestConfig.java b/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/TestConfig.java index da1a31e3f43d9..2eed41ce14834 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/TestConfig.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/TestConfig.java @@ -210,17 +210,6 @@ public interface TestConfig { @WithDefault("all") TestType type(); - /** - * If a class matches this pattern then it will be cloned into the Quarkus ClassLoader even if it - * is in a parent first artifact. - *
- * This is important for collections which can contain objects from the Quarkus ClassLoader, but for - * most parent first classes it will just cause problems. - */ - @WithDefault("java\\..*") - @Deprecated(forRemoval = true) - String classClonePattern(); - /** * If this is true then only the tests from the main application module will be run (i.e. the module that is currently * running mvn quarkus:dev). diff --git a/test-framework/junit5/src/main/java/io/quarkus/test/junit/internal/NewSerializingDeepClone.java b/test-framework/junit5/src/main/java/io/quarkus/test/junit/internal/NewSerializingDeepClone.java index c17be8f1b2c0f..6c65b336a49c1 100644 --- a/test-framework/junit5/src/main/java/io/quarkus/test/junit/internal/NewSerializingDeepClone.java +++ b/test-framework/junit5/src/main/java/io/quarkus/test/junit/internal/NewSerializingDeepClone.java @@ -5,7 +5,6 @@ import java.io.UncheckedIOException; import java.lang.reflect.Method; import java.util.function.Supplier; -import java.util.regex.Pattern; import org.jboss.marshalling.cloner.ClassCloner; import org.jboss.marshalling.cloner.ClonerConfiguration; @@ -20,7 +19,6 @@ */ public final class NewSerializingDeepClone implements DeepClone { private final ObjectCloner cloner; - private static Pattern clonePattern; private RunningQuarkusApplication runningQuarkusApplication; public NewSerializingDeepClone(final ClassLoader sourceLoader, final ClassLoader targetLoader) { @@ -55,46 +53,42 @@ public Class> cloneProxy(final Class> proxyClass) { } Class> theClassWeCareAbout = original.getClass(); - // Short-circuit the checks if we've been configured to clone this - if (!clonePattern.matcher(theClassWeCareAbout.getName()).matches()) { - - if (theClassWeCareAbout.isPrimitive()) { - // avoid copying things that do not need to be copied + if (theClassWeCareAbout.isPrimitive()) { + // avoid copying things that do not need to be copied + return original; + } else if (isUncloneable(theClassWeCareAbout)) { + if (original instanceof Supplier> s) { + // sneaky + return (Supplier>) () -> clone(s.get()); + } else { return original; - } else if (isUncloneable(theClassWeCareAbout)) { + } + } else if (original instanceof TestInfo info) { + // copy the test info correctly + return new TestInfoImpl(info.getDisplayName(), info.getTags(), + info.getTestClass() + .map(this::cloneClass), + info.getTestMethod() + .map(this::cloneMethod)); + } else { + try { + if (runningQuarkusApplication != null && runningQuarkusApplication.getClassLoader() + .loadClass(theClassWeCareAbout.getName()) == theClassWeCareAbout) { + // Don't clone things which are already loaded by the quarkus application's classloader side of the tree + return original; + } + } catch (ClassNotFoundException e) { + if (original instanceof Supplier> s) { // sneaky return (Supplier>) () -> clone(s.get()); } else { - return original; - } - } else if (original instanceof TestInfo info) { - // copy the test info correctly - return new TestInfoImpl(info.getDisplayName(), info.getTags(), - info.getTestClass() - .map(this::cloneClass), - info.getTestMethod() - .map(this::cloneMethod)); - } else { - try { - if (runningQuarkusApplication != null && runningQuarkusApplication.getClassLoader() - .loadClass(theClassWeCareAbout.getName()) == theClassWeCareAbout) { - // Don't clone things which are already loaded by the quarkus application's classloader side of the tree - return original; - } - } catch (ClassNotFoundException e) { - - if (original instanceof Supplier> s) { - // sneaky - return (Supplier>) () -> clone(s.get()); - } else { - throw e; - } + throw e; } + } - if (original == sourceLoader) { - return targetLoader; - } + if (original == sourceLoader) { + return targetLoader; } } @@ -140,9 +134,6 @@ public Object clone(final Object objectToClone) { @Override public void setRunningQuarkusApplication(RunningQuarkusApplication runningQuarkusApplication) { this.runningQuarkusApplication = runningQuarkusApplication; - String patternString = runningQuarkusApplication.getConfigValue("quarkus.test.class-clone-pattern", String.class) - .orElse("java\\..*"); - clonePattern = Pattern.compile(patternString); } }