Skip to content
Snippets Groups Projects
Commit f3df4180 authored by Tomasz Grabiec's avatar Tomasz Grabiec
Browse files

java: make runSync interrupt the context on which it waits

Interrupting a thread which is blocked waiting for an isolate to
complete which was started via runSync() should interrupt the isolate.
The waiter should return only after isolate terminated.

I think this is what users would expect to happen when interrupting a
foreground process.
parent 98d95bc2
No related branches found
No related tags found
No related merge requests found
......@@ -48,4 +48,8 @@ public final class Context {
public LogManagerWrapper getLogManagerWrapper() {
return logManagerWrapper.get();
}
public void interrupt() {
mainThread.interrupt();
}
}
......@@ -87,8 +87,17 @@ public class ContextIsolator {
public void runSync(String[] args) throws Throwable {
Context context = run(args);
if (context != null) {
context.join();
if (context == null) {
return;
}
while (true) {
try {
context.join();
return;
} catch (InterruptedException e) {
context.interrupt();
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment