Skip to content

Commit d38c190

Browse files
authored
Fix: Runloop thread name is always zio-kafka-runloop-thread-0 (#909)
1 parent bd59eca commit d38c190

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

zio-kafka/src/main/scala/zio/kafka/consumer/internal/RunloopExecutor.scala

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,18 @@ private[consumer] object RunloopExecutor {
99

1010
private val counter: AtomicLong = new AtomicLong(0)
1111

12-
private def newSingleThreadedExecutor(i: Long): ZIO[Scope, Throwable, Executor] =
12+
private val newSingleThreadedExecutor: ZIO[Scope, Throwable, Executor] =
1313
ZIO.acquireRelease {
1414
ZIO.attempt {
1515
val javaExecutor =
16-
Executors.newSingleThreadExecutor(runnable => new Thread(runnable, s"zio-kafka-runloop-thread-$i"))
16+
Executors.newSingleThreadExecutor { runnable =>
17+
new Thread(runnable, s"zio-kafka-runloop-thread-${counter.getAndIncrement()}")
18+
}
1719

1820
Executor.fromJavaExecutor(javaExecutor) -> javaExecutor
1921
}
2022
} { case (_, executor) => ZIO.attempt(executor.shutdown()).orDie }.map(_._1)
2123

22-
val newInstance: ZIO[Scope, Throwable, Executor] = newSingleThreadedExecutor(counter.getAndIncrement())
24+
val newInstance: ZIO[Scope, Throwable, Executor] = newSingleThreadedExecutor
2325

2426
}

0 commit comments

Comments
 (0)