From 0112cc26f08f9d605da6944bb076840faf5f01a0 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Mon, 7 Nov 2016 17:39:07 +0100 Subject: [PATCH] =?UTF-8?q?blockingGet=20=E2=80=94=20do=20not=20call=20awa?= =?UTF-8?q?it=20if=20not=20pending?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/org/jetbrains/concurrency/AsyncPromise.kt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/platform/projectModel-api/src/org/jetbrains/concurrency/AsyncPromise.kt b/platform/projectModel-api/src/org/jetbrains/concurrency/AsyncPromise.kt index a32c4f8ed4b8..b6312da03294 100644 --- a/platform/projectModel-api/src/org/jetbrains/concurrency/AsyncPromise.kt +++ b/platform/projectModel-api/src/org/jetbrains/concurrency/AsyncPromise.kt @@ -182,10 +182,12 @@ open class AsyncPromise : Promise, Getter { } override fun blockingGet(timeout: Int, timeUnit: TimeUnit): T? { - val latch = CountDownLatch(1) - processed { latch.countDown() } - if (!latch.await(timeout.toLong(), timeUnit)) { - throw TimeoutException() + if (isPending) { + val latch = CountDownLatch(1) + processed { latch.countDown() } + if (!latch.await(timeout.toLong(), timeUnit)) { + throw TimeoutException() + } } @Suppress("UNCHECKED_CAST")