Skip to content
This repository has been archived by the owner on Feb 9, 2019. It is now read-only.

play-plugins-redis: multiple tests would fail to get redis resource from redis pool #117

Open
angeloh opened this issue Jun 15, 2014 · 3 comments

Comments

@angeloh
Copy link

angeloh commented Jun 15, 2014

Multiple tests would fail to get redis resource from redis pool.

redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool
    at redis.clients.util.Pool.getResource(Pool.java:22)
    at org.sedis.Pool.withJedisClient(sedis.scala:79)
    at com.typesafe.plugin.RedisPlugin$$anon$1.get(RedisPlugin.scala:173)
    at play.api.cache.Cache$.get(Cache.scala:77)
    at play.api.cache.Cache$.getAs(Cache.scala:102)
    at controllers.Security$$anonfun$HasToken$1$$anonfun$apply$1.apply(Security.scala:79)
    at controllers.Security$$anonfun$HasToken$1$$anonfun$apply$1.apply(Security.scala:78)
    at scala.Option.flatMap(Option.scala:170)
    at controllers.Security$$anonfun$HasToken$1.apply(Security.scala:78)
    at controllers.Security$$anonfun$HasToken$1.apply(Security.scala:76)
    at play.api.mvc.ActionBuilder$$anonfun$apply$10.apply(Action.scala:221)
    at play.api.mvc.ActionBuilder$$anonfun$apply$10.apply(Action.scala:220)
    at actions.EnforceHttpsAction$$anonfun$invokeBlock$2.apply(EnforceHttps.scala:26)
    at actions.EnforceHttpsAction$$anonfun$invokeBlock$2.apply(EnforceHttps.scala:19)
    at scala.Option.getOrElse(Option.scala:120)
    at actions.EnforceHttpsAction$.invokeBlock(EnforceHttps.scala:18)
    at play.api.mvc.ActionBuilder$$anon$1.apply(Action.scala:309)
    at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$4$$anonfun$apply$5.apply(Action.scala:109)
    at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$4$$anonfun$apply$5.apply(Action.scala:109)
    at play.utils.Threads$.withContextClassLoader(Threads.scala:18)
    at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$4.apply(Action.scala:108)
    at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$4.apply(Action.scala:107)
    at scala.Option.map(Option.scala:145)
    at play.api.mvc.Action$$anonfun$apply$1.apply(Action.scala:107)
    at play.api.mvc.Action$$anonfun$apply$1.apply(Action.scala:100)
    at play.api.libs.iteratee.Iteratee$$anonfun$mapM$1.apply(Iteratee.scala:481)
    at play.api.libs.iteratee.Iteratee$$anonfun$mapM$1.apply(Iteratee.scala:481)
    at play.api.libs.iteratee.Iteratee$$anonfun$flatMapM$1.apply(Iteratee.scala:517)
    at play.api.libs.iteratee.Iteratee$$anonfun$flatMapM$1.apply(Iteratee.scala:517)
    at play.api.libs.iteratee.Iteratee$$anonfun$flatMap$1$$anonfun$apply$14.apply(Iteratee.scala:494)
    at play.api.libs.iteratee.Iteratee$$anonfun$flatMap$1$$anonfun$apply$14.apply(Iteratee.scala:494)
    at scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24)
    at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24)
    at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:42)
    at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:386)
    at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
    at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
    at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
    at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
Caused by: java.lang.IllegalStateException: Pool not open
    at org.apache.commons.pool.BaseObjectPool.assertOpen(BaseObjectPool.java:137)
    at org.apache.commons.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:1065)
    at redis.clients.util.Pool.getResource(Pool.java:20)
    ... 38 more

According to http://stackoverflow.com/questions/20888041/play-2-2-4-akka-tests-failed-when-run-together-but-ok-seperately, jedisPool might be already closed so next test is using invalid closed pool variable.

@angeloh angeloh changed the title Multiple tests would fail to get redis resource from redis pool play-plugins-redis: multiple tests would fail to get redis resource from redis pool Jun 15, 2014
@angeloh
Copy link
Author

angeloh commented Jun 26, 2014

@angeloh
Copy link
Author

angeloh commented Aug 7, 2014

According to this SO http://stackoverflow.com/questions/20888041/play-2-2-4-akka-tests-failed-when-run-together-but-ok-seperately, I think at RedisPlugin, jedisPool should change to a def.

 lazy val jedisPool = {
   val poolConfig = createPoolConfig(app)
   Logger.info(s"Redis Plugin enabled. Connecting to Redis on ${host}:${port} to ${database} with timeout ${timeout}.")
   Logger.info("Redis Plugin pool configuration: " + new ReflectionToStringBuilder(poolConfig).toString())
   new JedisPool(poolConfig, host, port, timeout, password, database)
 }

@ChristoRibeiro
Copy link

👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants