Skip to content

Commit 0fa1319

Browse files
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.
1 parent 30b06a9 commit 0fa1319

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/main/java/org/springframework/data/redis/connection/lettuce/LettuceConnectionFactory.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import org.springframework.data.redis.connection.RedisSentinelConfiguration;
4141
import org.springframework.data.redis.connection.RedisSentinelConnection;
4242
import org.springframework.util.Assert;
43+
import org.springframework.util.ClassUtils;
4344
import org.springframework.util.StringUtils;
4445

4546
import com.lambdaworks.redis.AbstractRedisClient;
@@ -147,8 +148,18 @@ public void afterPropertiesSet() {
147148
* @see org.springframework.beans.factory.DisposableBean#destroy()
148149
*/
149150
public void destroy() {
151+
150152
resetConnection();
151-
client.shutdown(shutdownTimeout, shutdownTimeout, TimeUnit.MILLISECONDS);
153+
154+
try {
155+
client.shutdown(shutdownTimeout, shutdownTimeout, TimeUnit.MILLISECONDS);
156+
} catch (Exception e) {
157+
158+
if (log.isWarnEnabled()) {
159+
log.warn((client != null ? ClassUtils.getShortName(client.getClass()) : "LettuceClient")
160+
+ " did not shut down gracefully.", e);
161+
}
162+
}
152163

153164
if (clusterCommandExecutor != null) {
154165

0 commit comments

Comments
 (0)