Skip to content

Commit 79d41de

Browse files
authored
Set specific class loader for config instance (#86)
1 parent 67ed71f commit 79d41de

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/main/java/com/nordstrom/automation/junit/JUnitConfig.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,15 @@ public String val() {
5555
private static final ThreadLocal<JUnitConfig> junitConfig = new InheritableThreadLocal<JUnitConfig>() {
5656
@Override
5757
protected JUnitConfig initialValue() {
58+
final ClassLoader original = Thread.currentThread().getContextClassLoader();
5859
try {
60+
final ClassLoader specific = LifecycleHooks.class.getClassLoader();
61+
Thread.currentThread().setContextClassLoader(specific);
5962
return new JUnitConfig();
6063
} catch (ConfigurationException | IOException e) {
6164
throw UncheckedThrow.throwUnchecked(e);
65+
} finally {
66+
Thread.currentThread().setContextClassLoader(original);
6267
}
6368
}
6469
};

src/main/java/com/nordstrom/automation/junit/Run.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ protected Deque<Object> initialValue() {
4848
public static void intercept(@This final Object runner, @SuperCall final Callable<?> proxy,
4949
@Argument(0) final RunNotifier notifier) throws Exception {
5050

51-
JUnitConfig.getConfig();
5251
RUNNER_TO_NOTIFIER.put(runner, notifier);
5352

5453
attachRunListeners(runner, notifier);

0 commit comments

Comments
 (0)