Skip to content

Commit 487a40e

Browse files
committed
ScriptModule: make context class loader non-null
Groovy assumes it will be non-null, and crashes if it's null. When is it null? Not totally clear. But it can happen! See its javadoc.
1 parent 309dc33 commit 487a40e

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/main/java/org/scijava/script/ScriptModule.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,13 @@ public ScriptInfo getInfo() {
123123

124124
@Override
125125
public void run() {
126+
// HACK: Work around code (Groovy!) assuming
127+
// context class loader can't be null.
128+
final ClassLoader cl = Thread.currentThread().getContextClassLoader();
129+
if (cl == null) {
130+
Thread.currentThread().setContextClassLoader(Context.getClassLoader());
131+
}
132+
126133
final ScriptEngine engine = getEngine();
127134
final String path = getInfo().getPath();
128135

0 commit comments

Comments
 (0)