From baea4a1cd731f3428606c3f95626130f8e40c722 Mon Sep 17 00:00:00 2001 From: "Tyler B. Thrailkill" Date: Tue, 18 Apr 2023 15:58:04 -0600 Subject: [PATCH] Use the current thread's classloader for classes Switch from using the caller's classloader to using the current thread's classloader. This will fix testcontainers#6923 and quarkusio/quarkus#32627 Please enter the commit message for your changes. Lines starting --- .../org/testcontainers/utility/ImageNameSubstitutor.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/org/testcontainers/utility/ImageNameSubstitutor.java b/core/src/main/java/org/testcontainers/utility/ImageNameSubstitutor.java index dae3f178230..3f491e4c9b3 100644 --- a/core/src/main/java/org/testcontainers/utility/ImageNameSubstitutor.java +++ b/core/src/main/java/org/testcontainers/utility/ImageNameSubstitutor.java @@ -33,7 +33,12 @@ public static synchronized ImageNameSubstitutor instance() { ImageNameSubstitutor configuredInstance; try { configuredInstance = - (ImageNameSubstitutor) Class.forName(configuredClassName).getConstructor().newInstance(); + (ImageNameSubstitutor) Thread + .currentThread() + .getContextClassLoader() + .loadClass(configuredClassName) + .getConstructor() + .newInstance(); } catch (Exception e) { throw new IllegalArgumentException( "Configured Image Substitutor could not be loaded: " + configuredClassName,