From cecbb34f60713f8cae7bc4d9ca5de53ca6c501f0 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Wed, 5 Apr 2017 17:19:48 +0200 Subject: [PATCH] =?UTF-8?q?if=20child=20is=20already=20resolved/rejected?= =?UTF-8?q?=20=E2=80=94=20no=20need=20to=20notify=20it?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/org/jetbrains/concurrency/AsyncPromise.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/platform/projectModel-api/src/org/jetbrains/concurrency/AsyncPromise.kt b/platform/projectModel-api/src/org/jetbrains/concurrency/AsyncPromise.kt index b6312da03294..9153b11c70f7 100644 --- a/platform/projectModel-api/src/org/jetbrains/concurrency/AsyncPromise.kt +++ b/platform/projectModel-api/src/org/jetbrains/concurrency/AsyncPromise.kt @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -78,6 +78,10 @@ open class AsyncPromise : Promise, Getter { override fun notify(child: AsyncPromise) { LOG.assertTrue(child !== this) + if (child.state != State.PENDING) { + return + } + when (state) { State.PENDING -> { addHandlers(Consumer({ child.catchError { child.setResult(it) } }), Consumer({ child.setError(it) }))