DATAREDIS-465 - Guard lettuce client shutdown during ConnectionFactory.destroy.
We now guard and log errors during lettuce client shutdown when destroying the ConnectionFactory on ApplicationContext shutdown.
This commit is contained in:
@@ -40,6 +40,7 @@ import org.springframework.data.redis.connection.RedisNode;
|
||||
import org.springframework.data.redis.connection.RedisSentinelConfiguration;
|
||||
import org.springframework.data.redis.connection.RedisSentinelConnection;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.lambdaworks.redis.AbstractRedisClient;
|
||||
@@ -147,8 +148,18 @@ public class LettuceConnectionFactory implements InitializingBean, DisposableBea
|
||||
* @see org.springframework.beans.factory.DisposableBean#destroy()
|
||||
*/
|
||||
public void destroy() {
|
||||
|
||||
resetConnection();
|
||||
client.shutdown(shutdownTimeout, shutdownTimeout, TimeUnit.MILLISECONDS);
|
||||
|
||||
try {
|
||||
client.shutdown(shutdownTimeout, shutdownTimeout, TimeUnit.MILLISECONDS);
|
||||
} catch (Exception e) {
|
||||
|
||||
if (log.isWarnEnabled()) {
|
||||
log.warn((client != null ? ClassUtils.getShortName(client.getClass()) : "LettuceClient")
|
||||
+ " did not shut down gracefully.", e);
|
||||
}
|
||||
}
|
||||
|
||||
if (clusterCommandExecutor != null) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user