天天看點

redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool

最近一段時間忙着做系統,又是大幾千行,寫得有點疲憊,就更新少了,還是應該堅持更新,好記性不如爛筆頭。

今天遇到個小問題,

redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool

jedis從連接配接池取連接配接失敗,導緻這個的原因比較多,我說下我這邊的問題。

redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool

上面乍一看,是沒問題,在finallly中釋放了連接配接,可實際上,擷取連接配接的那一句并沒有被try塊包圍起來,是以如果getJedis出現了異常,finally不會執行。

改成如下即可。

redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool