[DATAREDIS-1027] LettuceConnectionFactory.destroy() should release reactiveConnectionProvider resources Created: 15/Aug/19  Updated: 06/Sep/19  Resolved: 16/Aug/19

Status: Closed
Project: Spring Data Redis
Component/s: Lettuce Driver
Affects Version/s: None
Fix Version/s: 2.1.11 (Lovelace SR11), 2.2 RC3 (Moore)

Type: Bug Priority: Major
Reporter: Kevin Qian Assignee: Mark Paluch
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Last updater: Mark Paluch
Pull Request URL: https://github.com/spring-projects/spring-data-redis/pull/470
Sprint: Moore RC2

// code placeholder
public void destroy() {


   if (connectionProvider instanceof DisposableBean) {
      try {
         ((DisposableBean) connectionProvider).destroy();
      } catch (Exception e) {

         if (log.isWarnEnabled()) {
            log.warn(connectionProvider + " did not shut down gracefully.", e);

   try {
      Duration timeout = clientConfiguration.getShutdownTimeout();
      client.shutdown(timeout.toMillis(), timeout.toMillis(), 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) {

      try {
      } catch (Exception ex) {
         log.warn("Cannot properly close cluster command executor", ex);

should we need to invoke destroy method of reactiveConnectionProvider object to release resources?

Comment by Mark Paluch [ 15/Aug/19 ]

Good catch. It makes sense to dispose the reactive connection provider to release a backing connection pool.

Generated at Fri Jul 10 07:36:01 UTC 2020 using Jira 8.5.4#805004-sha1:0444eab799707f9ad7b248d69f858774aadfd250.