[log] IDEA-125309 One more fix for a possible deadlock

General practice is not to invoke some external code under a lock.

Here the result handler can safely be called before the lock: if new
requests arrive, they will be added to the queue in request(), and a new
background task will be started after result is handled.
This commit is contained in:
Kirill Likhodedov
2014-05-22 17:01:40 +04:00
parent f4b288b2ca
commit 9213ca50cb
@@ -85,8 +85,8 @@ public abstract class SingleTaskController<Request, Result> {
* The result is immediately passed to the result handler specified in the constructor.
*/
protected final void taskCompleted(@NotNull Result result) {
myResultHandler.consume(result);
synchronized (LOCK) {
myResultHandler.consume(result);
if (myAwaitingRequests.isEmpty()) {
myActive = false;
}