[concurrency-interest] Java 8 CompletableFuture.thenCombine() hangs
peter.levart at gmail.com
Thu Apr 3 11:06:43 EDT 2014
On 04/03/2014 01:08 PM, Doug Lea wrote:
> On 04/03/2014 04:28 AM, Paul Sandoz wrote:
>> It appears to be caused by a StackOverflowException being thrown when an
>> async task attempts to complete all its dependent tasks in the
>> chain. That exception gets swallowed and does not propagate.
> Thanks! I'll look into ways of ensuring that StackOverflowException,
> OutOfMemoryError, and the like at least get reported. These have
> a history of being difficult to deal with, but we can surely do
Hi Doug, Paul,
This explains why I saw a CompletableFuture with result != null (done),
but it still had a non-empty stack of Completers left behind.
Paul's idea of having an off-stack "stack" is easily achievable. There
already is such a stack - the CompletableFuture.completers stack.
Here's a dirty hack that (ab)uses it:
The re-linking of Completers from one CompletableFuture's stack to the
other's does reverse the order of execution of Completers that were
initially added to the stack of the first CompletableFuture. Does the
order of execution of Completers matter?
Anyway, the thenCombine() test passes with that change.
> Concurrency-interest mailing list
> Concurrency-interest at cs.oswego.edu
More information about the Concurrency-interest