I looked at the SwingBuilder source for Groovy 1.8.9, and it turns out that doOutside
uses ExecutorService.submit()
if it is invoked from the EDT thread:
private static final ExecutorService DEFAULT_EXECUTOR_SERVICE = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors())
...
DEFAULT_EXECUTOR_SERVICE.submit(c)
The submit()
returns a Future
, which gets thrown away, as you can see above. A Future
traps its exceptions and only throws an exception itself if you call Future.get()
. But that never happens in doOutside()
.
So I need put a try-catch inside the closure I pass to doOutside()
to be able to notice that an exception happened there.
NOTE: The Future
was replaced with a simple Thread.start()
in Groovy 2.1.0-rc-1 (see bug https://issues.apache.org/jira/browse/GROOVY-5074). That removes the exception trapping problem.