Skip to content

Commit

Permalink
Remove config which isn't really useful anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
holly-cummins committed Nov 18, 2024
1 parent 6e4206e commit 3e8de31
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
* <p>
* 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).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand Down Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -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);
}

}

0 comments on commit 3e8de31

Please sign in to comment.