From 8592751d603a2893e752bbff0d2ac6713c46a611 Mon Sep 17 00:00:00 2001 From: John Griffey Date: Wed, 2 May 2018 06:25:37 -0600 Subject: [PATCH 1/2] Configure AsyncExecutor to prevent warning See https://github.com/slick/slick/blob/884e221b7b471efe05458ff56530f896259971da/slick/src/main/scala/slick/util/AsyncExecutor.scala#L41 for more details regarding the configuration options. --- src/main/scala/ScalatraBootstrap.scala | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/scala/ScalatraBootstrap.scala b/src/main/scala/ScalatraBootstrap.scala index 363bc291..5ef217b4 100644 --- a/src/main/scala/ScalatraBootstrap.scala +++ b/src/main/scala/ScalatraBootstrap.scala @@ -32,7 +32,15 @@ class ScalatraBootstrap extends LifeCycle { */ override def init(context: ServletContext) { // val db = if (cpds != null) Database.forDataSource(cpds) else null - val db = if (cpds != null) Database.forDataSource(cpds, Option(50)) else null + val maxConns = ExchConfig.getInt("api.db.maxPoolSize") + val db = + if (connPool != null) { + Database.forDataSource( + connPool, + Some(maxConns), + AsyncExecutor("ExchangeExecutor", maxConns, maxConns, 1000, maxConns) + ) + } else null // Disable scalatra's builtin CorsSupport because for some inexplicable reason it doesn't set Access-Control-Allow-Origin which is critical context.setInitParameter("org.scalatra.cors.enable", "false") @@ -72,4 +80,4 @@ class ScalatraBootstrap extends LifeCycle { cpds.setAcquireIncrement(ExchConfig.getInt("api.db.acquireIncrement")) cpds.setMaxPoolSize(ExchConfig.getInt("api.db.maxPoolSize")) } -} \ No newline at end of file +} From 27a90f1b685a5753e7e2eb5436271c73636d1e45 Mon Sep 17 00:00:00 2001 From: John Griffey Date: Wed, 2 May 2018 06:57:24 -0600 Subject: [PATCH 2/2] Rename variable I pulled this out of another branch with other changes and didn't make sure it was correct here on its own. :facepalm: --- src/main/scala/ScalatraBootstrap.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/scala/ScalatraBootstrap.scala b/src/main/scala/ScalatraBootstrap.scala index 5ef217b4..5330cc6a 100644 --- a/src/main/scala/ScalatraBootstrap.scala +++ b/src/main/scala/ScalatraBootstrap.scala @@ -34,9 +34,9 @@ class ScalatraBootstrap extends LifeCycle { // val db = if (cpds != null) Database.forDataSource(cpds) else null val maxConns = ExchConfig.getInt("api.db.maxPoolSize") val db = - if (connPool != null) { + if (cpds != null) { Database.forDataSource( - connPool, + cpds, Some(maxConns), AsyncExecutor("ExchangeExecutor", maxConns, maxConns, 1000, maxConns) )