Skip to content

jedis: IllegalStateException: Object has already been returned to this pool or is invalid #732

@pierredavidbelanger

Description

@pierredavidbelanger

Using jooby 1.1.0, with this simple code (inspired by this doc):

use(new Redis());

get("/redis", () -> {
    try (Jedis jedis = require(Jedis.class)) {
        jedis.get("dummy");
        return "HelloWorld!";
    }
});

and this config:

db = "redis://localhost:6379"

When I access /redis the first time it works, then every other request fails with:

Stacktrace:
org.jooby.Err: Server Error(500)
	at org.jooby.internal.HttpHandlerImpl.handleErr(HttpHandlerImpl.java:405)
	at org.jooby.internal.HttpHandlerImpl.cleanup(HttpHandlerImpl.java:378)
	at org.jooby.internal.HttpHandlerImpl.handle(HttpHandlerImpl.java:320)
	at org.jooby.internal.undertow.UndertowHandler.handleRequest(UndertowHandler.java:67)
	at io.undertow.server.Connectors.executeRootHandler(Connectors.java:211)
	at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:809)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
Caused by: redis.clients.jedis.exceptions.JedisException: Could not return the resource to the pool
	at redis.clients.jedis.JedisPool.returnResource(JedisPool.java:129)
	at redis.clients.jedis.JedisPool.returnResource(JedisPool.java:12)
	at redis.clients.jedis.Jedis.close(Jedis.java:3357)
	at ca.routeo.App.lambda$new$0(App.java:90)
	at org.jooby.Route$ZeroArgHandler.handle(Route.java:1797)
	at org.jooby.internal.RouteImpl.handle(RouteImpl.java:97)
	at org.jooby.internal.RouteChain.next(RouteChain.java:77)
	at org.jooby.Route$Chain.next(Route.java:2109)
	at org.jooby.internal.HttpHandlerImpl.handle(HttpHandlerImpl.java:312)
	... 6 common frames omitted
Caused by: redis.clients.jedis.exceptions.JedisException: Could not return the resource to the pool
	at redis.clients.util.Pool.returnResourceObject(Pool.java:69)
	at redis.clients.jedis.JedisPool.returnResource(JedisPool.java:126)
	... 14 common frames omitted
Caused by: java.lang.IllegalStateException: Object has already been returned to this pool or is invalid
	at org.apache.commons.pool2.impl.GenericObjectPool.returnObject(GenericObjectPool.java:551)
	at redis.clients.util.Pool.returnResourceObject(Pool.java:67)
	... 15 common frames omitted

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions