[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

 Description   
// code placeholder
public void destroy() {

   resetConnection();

   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 {
         clusterCommandExecutor.destroy();
      } 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?



 Comments   
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 Jan 24 06:11:52 UTC 2020 using Jira 7.13.8#713008-sha1:1606a5c1e7006e1ab135aac81f7a9566b2dbc3a6.