If it is not possible to create the resource, keep trying until it can

This commit is contained in:
Jonathan Leibiusky
2010-09-07 17:10:52 -03:00
parent e6105efd69
commit 1d37728817

View File

@@ -1,8 +1,5 @@
package redis.clients.jedis; package redis.clients.jedis;
import java.io.IOException;
import java.net.UnknownHostException;
import redis.clients.util.FixedResourcePool; import redis.clients.util.FixedResourcePool;
public class JedisPool extends FixedResourcePool<Jedis> { public class JedisPool extends FixedResourcePool<Jedis> {
@@ -29,12 +26,17 @@ public class JedisPool extends FixedResourcePool<Jedis> {
@Override @Override
protected Jedis createResource() { protected Jedis createResource() {
Jedis jedis = new Jedis(this.host, this.port, this.timeout); Jedis jedis = new Jedis(this.host, this.port, this.timeout);
try { boolean done = false;
jedis.connect(); while (!done) {
} catch (UnknownHostException e) { try {
throw new JedisException(e); jedis.connect();
} catch (IOException e) { done = true;
throw new JedisException(e); } catch (Exception e) {
try {
Thread.sleep(100);
} catch (InterruptedException e1) {
}
}
} }
return jedis; return jedis;
} }