• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2016-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3  */
4 
5 package kotlinx.coroutines
6 
7 import org.junit.*
8 
9 class AwaitJvmTest : TestBase() {
10     @Test
<lambda>null11     public fun testSecondLeak() = runTest {
12         // This test is to make sure that handlers installed on the second deferred do not leak
13         val d1 = CompletableDeferred<Int>()
14         val d2 = CompletableDeferred<Int>()
15         d1.completeExceptionally(TestException()) // first is crashed
16         val iterations = 3_000_000 * stressTestMultiplier
17         for (iter in 1..iterations) {
18             try {
19                 awaitAll(d1, d2)
20                 expectUnreached()
21             } catch (e: TestException) {
22                 expect(iter)
23             }
24         }
25         finish(iterations + 1)
26     }
27 }