Skip to content

Commit 1a61543

Browse files
authored
Use the current thread's classloader for classes (#6926)
Switch from using the caller's classloader to using the current thread's classloader.
1 parent b50cfee commit 1a61543

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

core/src/main/java/org/testcontainers/utility/ImageNameSubstitutor.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,12 @@ public static synchronized ImageNameSubstitutor instance() {
3333
ImageNameSubstitutor configuredInstance;
3434
try {
3535
configuredInstance =
36-
(ImageNameSubstitutor) Class.forName(configuredClassName).getConstructor().newInstance();
36+
(ImageNameSubstitutor) Thread
37+
.currentThread()
38+
.getContextClassLoader()
39+
.loadClass(configuredClassName)
40+
.getConstructor()
41+
.newInstance();
3742
} catch (Exception e) {
3843
throw new IllegalArgumentException(
3944
"Configured Image Substitutor could not be loaded: " + configuredClassName,

0 commit comments

Comments
 (0)