Implements Closeable to Pooled Jedis & ShardedJedis
* Implement Closeable from Jedis, ShardedJedis with Pooled ** resources from JedisPool, JedisSentinelPool, ShardedJedis, ShardedJedisPool * Connection class : check whether Jedis Connection is broken ** when it's time to throw JedisConnectionException, mark Connection to broken
This commit is contained in:
@@ -302,4 +302,25 @@ public class ShardedJedisTest extends Assert {
|
||||
assertEquals(jedisShardInfo.getName(), jedisShardInfo2.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkCloseable() {
|
||||
List<JedisShardInfo> shards = new ArrayList<JedisShardInfo>();
|
||||
shards.add(new JedisShardInfo(redis1.getHost(), redis1.getPort()));
|
||||
shards.add(new JedisShardInfo(redis2.getHost(), redis2.getPort()));
|
||||
shards.get(0).setPassword("foobared");
|
||||
shards.get(1).setPassword("foobared");
|
||||
|
||||
ShardedJedis jedisShard = new ShardedJedis(shards);
|
||||
try {
|
||||
jedisShard.set("shard_closeable", "true");
|
||||
} finally {
|
||||
jedisShard.close();
|
||||
}
|
||||
|
||||
for (Jedis jedis : jedisShard.getAllShards()) {
|
||||
assertTrue(!jedis.isConnected());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user