Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,11 @@ public void checkCloseableConnections() throws Exception {

JedisSentinelPool pool = new JedisSentinelPool(MASTER_NAME, sentinels, config, 1000,
"default","foobared", 2);
Jedis jedis = pool.getResource();
jedis.auth("default", "foobared");
jedis.set("foo", "bar");
assertEquals("bar", jedis.get("foo"));
jedis.close();
try(Jedis jedis = pool.getResource()){
jedis.auth("default", "foobared");
jedis.set("foo", "bar");
assertEquals("bar", jedis.get("foo"));
}
pool.close();
assertTrue(pool.isClosed());
}
Expand All @@ -128,24 +128,23 @@ public void returnResourceShouldResetState() {
GenericObjectPoolConfig config = new GenericObjectPoolConfig();
config.setMaxTotal(1);
config.setBlockWhenExhausted(false);
JedisSentinelPool pool = new JedisSentinelPool(MASTER_NAME, sentinels, config, 1000,
"default", "foobared", 2);

Jedis jedis = pool.getResource();
try {
jedis.set("hello", "jedis");
Transaction t = jedis.multi();
t.set("hello", "world");
jedis.close();
try (JedisSentinelPool pool = new JedisSentinelPool(MASTER_NAME, sentinels, config, 1000,
"default", "foobared", 2)){
Jedis jedis;
try (Jedis jedis1 = pool.getResource()){
jedis = jedis1;
jedis1.set("hello", "jedis");
Transaction t = jedis1.multi();
t.set("hello", "world");
jedis1.close();
}

try (Jedis jedis2 = pool.getResource()) {

assertSame(jedis, jedis2);
assertEquals("jedis", jedis2.get("hello"));
}
} finally {

pool.destroy();
}
}

Expand All @@ -157,11 +156,10 @@ public void checkResourceIsCloseable() {
try(JedisSentinelPool pool = new JedisSentinelPool(MASTER_NAME, sentinels, config, 1000,
"default", "foobared", 2)){

Jedis jedis = pool.getResource();
try {
jedis.set("hello", "jedis");
} finally {
jedis.close();
Jedis jedis;
try (Jedis jedis1 = pool.getResource()){
jedis = jedis1;
jedis1.set("hello", "jedis");
}

try (Jedis jedis2 = pool.getResource()){
Expand All @@ -178,12 +176,9 @@ public void customClientName() {
JedisSentinelPool pool = new JedisSentinelPool(MASTER_NAME, sentinels, config, 1000,
"default", "foobared", 0, "my_shiny_client_name");

Jedis jedis = pool.getResource();

try {
try (Jedis jedis = pool.getResource()){
assertEquals("my_shiny_client_name", jedis.clientGetname());
} finally {
jedis.close();
pool.destroy();
}

Expand Down