If it is not possible to create the resource, keep trying until it can
This commit is contained in:
@@ -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);
|
||||||
|
boolean done = false;
|
||||||
|
while (!done) {
|
||||||
try {
|
try {
|
||||||
jedis.connect();
|
jedis.connect();
|
||||||
} catch (UnknownHostException e) {
|
done = true;
|
||||||
throw new JedisException(e);
|
} catch (Exception e) {
|
||||||
} catch (IOException e) {
|
try {
|
||||||
throw new JedisException(e);
|
Thread.sleep(100);
|
||||||
|
} catch (InterruptedException e1) {
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return jedis;
|
return jedis;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user