redis踩坑记录:Could not get a resource from the pool

报错场景

jedis 2.9.0
spring-data-redis-1.7.1
redis 5.0.5
spring 4
jdk 1.8

配置jedis连接池获取jedis实例出现下面异常
org.springframework.data.redis.RedisConnectionFailureException: Cannot get Jedis connection; nested exception is redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool

从异常信息中获取到的信息是:无法从池中拿到jedis实例从而报错

查看源码当走到
在设置jedis密码时:JedisFactory.class 97行
redis踩坑记录:Could not get a resource from the pool
这个地方发生了异常:
redis.clients.jedis.exceptions.JedisDataException: ERR Client sent AUTH, but no password is set

判断应该是密码没有设置或者是密码错误

检查redis配置文件和项目配置文件,防火墙等等等都没有问题!

只能继续深追源码。。。。

F5进入jedis.auth(password);
走到Connection.class
redis踩坑记录:Could not get a resource from the pool
发现在代码中会把密码encode .

突然redis的密码是包含 #$ 这种特殊字符,猜想是不是这个原因造成。

解决

把redis的连接密码设置成字母加数字。重启后正常。

原因

目前还没有找到。。。。

有同样的小伙伴欢迎留言说下原因。。。。