Let the user choose whether to testOnBorrow or testOnReturn

Force testOnBorrow if neither is specified.
This commit is contained in:
Nelson Rodrigues
2014-07-28 11:44:23 -07:00
parent fceb719848
commit d52cc06b72

View File

@@ -65,8 +65,10 @@ public class JedisSentinelPool extends Pool<Jedis> {
public JedisSentinelPool(String masterName, Set<String> sentinels,
final GenericObjectPoolConfig poolConfig, int timeout,
final String password, final int database) {
// Proper master failover detection dependes on testOnBorrow, so force it here
poolConfig.setTestOnBorrow(true);
// Proper master failover detection dependes on testOnBorrow or testOnReturn, so force it here
if (!poolConfig.getTestOnBorrow() && !poolConfig.getTestOnReturn()) {
poolConfig.setTestOnBorrow(true);
}
this.poolConfig = poolConfig;
this.timeout = timeout;