Skip to content

Commit d641514

Browse files
committed
Use a CountDownLatch to state the intent more clearly
1 parent 62d6702 commit d641514

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

adapter/src/test/kotlin/org/javacs/ktda/SampleWorkspaceTest.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ import org.hamcrest.Matchers.equalTo
1515
import org.hamcrest.Matchers.hasItem
1616
import org.hamcrest.Matchers.nullValue
1717
import org.hamcrest.Matchers.not
18-
import java.util.concurrent.Semaphore
18+
import java.util.concurrent.CountDownLatch
1919

2020
/**
2121
* Tests a very basic debugging scenario
2222
* using a sample application.
2323
*/
2424
class SampleWorkspaceTest : DebugAdapterTestFixture("sample-workspace", "sample.workspace.AppKt") {
25-
private val semaphore = Semaphore(0)
25+
private val latch = CountDownLatch(1)
2626
private var asyncException: Throwable? = null
2727

2828
@Test fun testBreakpointsAndVariables() {
@@ -44,7 +44,7 @@ class SampleWorkspaceTest : DebugAdapterTestFixture("sample-workspace", "sample.
4444
}).join()
4545

4646
launch()
47-
semaphore.acquire() // Wait for the end
47+
latch.await() // Wait for the breakpoint event to finish
4848
asyncException?.let { throw it }
4949
}
5050

@@ -78,7 +78,7 @@ class SampleWorkspaceTest : DebugAdapterTestFixture("sample-workspace", "sample.
7878
} catch (e: Throwable) {
7979
asyncException = e
8080
} finally {
81-
semaphore.release()
81+
latch.countDown()
8282
}
8383
}
8484
}

0 commit comments

Comments
 (0)