Skip to content

Commit

Permalink
Try "inUseCount" as field name
Browse files Browse the repository at this point in the history
  • Loading branch information
trevorsibanda committed Jul 4, 2017
1 parent fb9258a commit 4a401b4
Showing 1 changed file with 6 additions and 1 deletion.
Expand Up @@ -14,6 +14,7 @@ import slick.util.SlickLogger


import scala.concurrent.duration._ import scala.concurrent.duration._
import scala.concurrent.{Await, Future} import scala.concurrent.{Await, Future}
import scala.util.{Try, Success}


class SlickInUseCountTest extends AsyncTest[JdbcTestDB] { class SlickInUseCountTest extends AsyncTest[JdbcTestDB] {


Expand Down Expand Up @@ -84,7 +85,11 @@ class SlickInUseCountTest extends AsyncTest[JdbcTestDB] {
val threadPoolExecutor = threadPoolExecutorField.get(asyncExecutor) val threadPoolExecutor = threadPoolExecutorField.get(asyncExecutor)


val queue = threadPoolExecutor.getClass.getMethod("getQueue").invoke(threadPoolExecutor) val queue = threadPoolExecutor.getClass.getMethod("getQueue").invoke(threadPoolExecutor)
val inUseCountField = queue.getClass.getDeclaredField("slick$util$ManagedArrayBlockingQueue$$inUseCount") val inUseCountField = Seq("inUseCount", "slick$util$ManagedArrayBlockingQueue$$inUseCount").collectFirst{name =>
Try(queue.getClass.getDeclaredField(name)) match{
case Success(field) => field
}
}.get
inUseCountField.setAccessible(true) inUseCountField.setAccessible(true)


inUseCountField.get(queue).asInstanceOf[Int] inUseCountField.get(queue).asInstanceOf[Int]
Expand Down

0 comments on commit 4a401b4

Please sign in to comment.