Skip to content

Commit 7647ab1

Browse files
committed
Jython polling thread: log errors
Pass a LogService to the thread polling the PhantomReference queue so that exceptions can be logged.
1 parent 70e0c18 commit 7647ab1

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/main/java/org/scijava/plugins/scripting/jython/JythonScriptLanguage.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import org.python.core.PyObject;
4444
import org.python.core.PyString;
4545
import org.python.util.PythonInterpreter;
46+
import org.scijava.log.LogService;
4647
import org.scijava.plugin.Parameter;
4748
import org.scijava.plugin.Plugin;
4849
import org.scijava.script.AdaptedScriptLanguage;
@@ -71,6 +72,9 @@ public class JythonScriptLanguage extends AdaptedScriptLanguage {
7172
@Parameter
7273
private ThreadService threadService;
7374

75+
@Parameter
76+
private LogService logService;
77+
7478
public JythonScriptLanguage() {
7579
super("jython");
7680
}
@@ -79,6 +83,7 @@ public JythonScriptLanguage() {
7983
public ScriptEngine getScriptEngine() {
8084
// TODO: Consider adapting the wrapped ScriptEngineFactory's ScriptEngine.
8185
final JythonScriptEngine engine = new JythonScriptEngine();
86+
final LogService ls = logService;
8287

8388
synchronized (phantomReferences) {
8489
// NB: This phantom reference is used to clean up any local variables
@@ -128,6 +133,7 @@ public void run() {
128133
}
129134
catch (final Exception ex) {
130135
// log exception, continue
136+
ls.error(ex);
131137
}
132138
}
133139
}

0 commit comments

Comments
 (0)