Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
3.0.5, 2.5.13
-
None
-
None
Description
When ExecutorService is used with the @Delegate annotation, then casting a Closure to a Callable doesn't seem to call the correct method (we suspect it's calling the Runnable method)
Given the following script:
import java.util.concurrent.Callable import java.util.concurrent.ExecutorService import java.util.concurrent.Executors import java.util.concurrent.Future import java.util.concurrent.TimeUnit class MyService { @Delegate ExecutorService delegateExecutorService = Executors.newCachedThreadPool() } def test(ExecutorService s) { println s.submit { 42 }.get() println s.submit([call: { 42 }] as Callable).get() println s.submit({ 42 } as Callable).get() s.shutdownNow() } println "Delegated ExecutorService" test(new MyService()) println() println "Actual ExecutorService" test(Executors.newCachedThreadPool())
The output is:
Delegated ExecutorService null 42 null Actual ExecutorService null 42 42
Whereas I was expecting the first delegated result to be the same as calling the actual executor service...
Apologies if this is a dupe, or documented, I did try and look, but to no avail
Cheers
Tim