Affects Version/s: None
Fix Version/s: None
Steps to reproduce:
Consider the following code:
Then use RedisWrapper bean to access redis data.
RedisTemplate reports error when a uninitialized ConnectionFactory is set.
RedisTemplate automatically initialize (call ConnectionFactory.afterPropertiesSet() ) the supplied ConnectionFactory is not initialized (generally not a bean).
These code will code NPE while reading data from Redis, since the pool in JedisConnectionFactory is not initialized by BeanFactory. (RedisConnectionFactory is not a bean). Developers won't know this before they actually access redis data.
By calling connectionFactory.afterPropertiesSet() and redisTemplateObject.afterPropertiesSet() will fix this problem. However, this delays discovery of configuration error to call time.
No document says that afterPropertiesSet() must be called when RedisConnectionFactory in created manually.
- Developer call afterPropertiesSet() after initiate RedisTemplate and ConnectionFactory.
- Developer implements InitializingBean and manually call afterPropertiesSet() for RedisTemplate and ConnectionFactory.
- Document ConnectionFactory and RedisTemplate, tell them to call afterPropertiesSet() in such case.