Closed maximdim closed 11 years ago
Thanks for contributing, Dmitri. It looks better this way indeed.
However, there is a little problem with your test. You specified SyncExecutor for the flow, and this executor runs on the same thread where the flow was started. Therefore, by the time you call waitForCompletion, it's already completed. With SyncExecutor there is no need in waitForCompletion call.
Andrey,
Indeed you're right, now when I look at it it makes sense, but it wan't immediately obvious when I wrote code initially. I think that correct behaviour for waitForComplation() in such case should be not too block at all, which is what achieved with the patch. Glad you found it useful.
In my case, test never finishes with original synchronize/notify approach for flow.waitForCompletion() (see SynchronizationTest.java). I have refactored it to CountdownLatch - think it's a bit cleaner this way as well.