Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ConnectionPool and BrokenConnection #437

Closed
giridharkannan opened this issue Jul 20, 2013 · 2 comments
Closed

ConnectionPool and BrokenConnection #437

giridharkannan opened this issue Jul 20, 2013 · 2 comments

Comments

@giridharkannan
Copy link

As of present implementation if there has occurred an IOException it will be wrapped over JedisConnectionException (RuntimeException). As jedis users, When we use ConnectionPool we just get and release connection in a try finally block, we forget the catch block.

Here's an example:

try {
    Jedis conn = getConn();
    conn.set("foo","bar");
} finally {
   release(conn);
}

If closing and returning a broken connection when IOEception occurs had been handled by jedis it would be much easier. As at present we are using already closed connection from the pool and writing to it, which result in a inconsistent state.

@mindwind
Copy link
Contributor

jedis can not do that, i think. Because jedis instance can not control the pool, you must use as follows or encapsulate jedis yourself for easier using.

Jedis conn = getConn();
try {
    conn.set("foo","bar");
} catch(JedisConnectionException e) {
    pool.returnBrokenResource(conn);
} finally {
   release(conn);
}

@marcosnils
Copy link
Contributor

Resource cleanup has been unified in Jedis.close function.

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

No branches or pull requests

3 participants