Browse files

Database.forConfig uses provided config params `numThreads` and `queu…


The existing implementation of Database.forConfig was ignoring the `path`
passed to it when looking up the value of `numThreads` and `queueSize` in
the config.

I would have loved to provide a test together with the fix, but I would have
to resort to reflection to retrieve the values used to set up the thread pool,
and that seems fragile. Therefore, there is no test with this fix.
  • Loading branch information...
dotta committed Aug 11, 2015
1 parent 9e28dec commit 75146666627f26b796a36df75f2e03fb421b8a85
Showing with 3 additions and 2 deletions.
  1. +3 −2 slick/src/main/scala/slick/jdbc/JdbcBackend.scala
@@ -263,8 +263,9 @@ trait JdbcBackend extends RelationalBackend {
def forConfig(path: String, config: Config = ConfigFactory.load(), driver: Driver = null,
classLoader: ClassLoader = ClassLoaderUtil.defaultClassLoader): Database = {
val source = JdbcDataSource.forConfig(if(path.isEmpty) config else config.getConfig(path), driver, path, classLoader)
val executor = AsyncExecutor(path, config.getIntOr("numThreads", 20), config.getIntOr("queueSize", 1000))
val usedConfig = if(path.isEmpty) config else config.getConfig(path)
val source = JdbcDataSource.forConfig(usedConfig, driver, path, classLoader)
val executor = AsyncExecutor(path, usedConfig.getIntOr("numThreads", 20), usedConfig.getIntOr("queueSize", 1000))
forSource(source, executor)

0 comments on commit 7514666

Please sign in to comment.