@@ -80,27 +80,30 @@ public String getPassword() {
80
80
public void timeoutConnection () throws Exception {
81
81
Jedis jedis = new Jedis ("localhost" , 6379 , 15000 );
82
82
jedis .auth ("foobared" );
83
- String timeout = jedis .configGet ("timeout" ).get (1 );
84
- jedis .configSet ("timeout" , "1" );
85
- Thread .sleep (2000 );
83
+ // read current config
84
+ final String timeout = jedis .configGet ("timeout" ).get (1 );
86
85
try {
87
- jedis .hmget ("foobar" , "foo" );
88
- fail ("Operation should throw JedisConnectionException" );
89
- } catch (JedisConnectionException jce ) {
90
- // expected
86
+ jedis .configSet ("timeout" , "1" );
87
+ Thread .sleep (5000 );
88
+ try {
89
+ jedis .hmget ("foobar" , "foo" );
90
+ fail ("Operation should throw JedisConnectionException" );
91
+ } catch (JedisConnectionException jce ) {
92
+ // expected
93
+ }
94
+ jedis .close ();
95
+ } finally {
96
+ // reset config
97
+ jedis = new Jedis ("localhost" , 6379 );
98
+ jedis .auth ("foobared" );
99
+ jedis .configSet ("timeout" , timeout );
100
+ jedis .close ();
91
101
}
92
- jedis .close ();
93
-
94
- // reset config
95
- jedis = new Jedis ("localhost" , 6379 );
96
- jedis .auth ("foobared" );
97
- jedis .configSet ("timeout" , timeout );
98
- jedis .close ();
99
102
}
100
103
101
104
@ Test
102
105
public void infiniteTimeout () throws Exception {
103
- try (Jedis timeoutJedis = new Jedis ("localhost" , 6379 , 350 , 350 , 350 )) {
106
+ try (Jedis timeoutJedis = new Jedis ("localhost" , 6379 , 200 , 200 , 200 )) {
104
107
timeoutJedis .auth ("foobared" );
105
108
try {
106
109
timeoutJedis .blpop (0 , "foo" );
0 commit comments