mirror of
https://github.com/corda/corda.git
synced 2025-02-21 01:42:24 +00:00
Attempt to fix AffinityExecutorTest and fix an IDE hint.
This test sometimes fails on Jenkins but I can't reproduce the failure here. There is a race in the tests though, I think this should fix it.
This commit is contained in:
parent
e3727a1de6
commit
fac38e1f3f
@ -53,7 +53,7 @@ interface AffinityExecutor : Executor {
|
||||
*/
|
||||
class ServiceAffinityExecutor(threadName: String, numThreads: Int) : AffinityExecutor,
|
||||
ThreadPoolExecutor(numThreads, numThreads, 0L, TimeUnit.MILLISECONDS, LinkedBlockingQueue<Runnable>()) {
|
||||
protected val threads = Collections.synchronizedSet(HashSet<Thread>())
|
||||
private val threads = Collections.synchronizedSet(HashSet<Thread>())
|
||||
private val uncaughtExceptionHandler = Thread.currentThread().uncaughtExceptionHandler
|
||||
|
||||
init {
|
||||
|
@ -59,18 +59,20 @@ class AffinityExecutorTests {
|
||||
assert(!executor.isOnThread)
|
||||
|
||||
val latch = CountDownLatch(1)
|
||||
val latch2 = CountDownLatch(2)
|
||||
val threads = Collections.synchronizedList(ArrayList<Thread>())
|
||||
|
||||
fun blockAThread() {
|
||||
executor.execute {
|
||||
assert(executor.isOnThread)
|
||||
threads += Thread.currentThread()
|
||||
latch2.countDown()
|
||||
latch.await()
|
||||
}
|
||||
}
|
||||
blockAThread()
|
||||
blockAThread()
|
||||
executor.flush()
|
||||
latch2.await()
|
||||
assertEquals(2, threads.size)
|
||||
val numThreads = executor.fetchFrom {
|
||||
assert(executor.isOnThread)
|
||||
|
Loading…
x
Reference in New Issue
Block a user