Fixed - Spring Data RedissonConnectionFactory should call shutdown method on destroy on created Redisson instance. #2509

pull/2517/head
Nikita Koksharov 5 years ago
parent 5748ca0432
commit 2d31e52243

@ -40,7 +40,8 @@ import org.springframework.data.redis.connection.RedisSentinelConnection;
* @author Nikita Koksharov
*
*/
public class RedissonConnectionFactory implements RedisConnectionFactory, InitializingBean, DisposableBean {
public class RedissonConnectionFactory implements RedisConnectionFactory,
InitializingBean, DisposableBean {
private final static Log log = LogFactory.getLog(RedissonConnectionFactory.class);
@ -49,12 +50,14 @@ public class RedissonConnectionFactory implements RedisConnectionFactory, Initia
private Config config;
private RedissonClient redisson;
private boolean hasOwnRedisson;
/**
* Creates factory with default Redisson configuration
*/
public RedissonConnectionFactory() {
this(Redisson.create());
hasOwnRedisson = true;
}
/**
@ -74,6 +77,7 @@ public class RedissonConnectionFactory implements RedisConnectionFactory, Initia
public RedissonConnectionFactory(Config config) {
super();
this.config = config;
hasOwnRedisson = true;
}
@Override
@ -83,6 +87,9 @@ public class RedissonConnectionFactory implements RedisConnectionFactory, Initia
@Override
public void destroy() throws Exception {
if (hasOwnRedisson) {
redisson.shutdown();
}
}
@Override

@ -30,13 +30,7 @@ import org.springframework.dao.DataAccessException;
import org.springframework.dao.InvalidDataAccessResourceUsageException;
import org.springframework.data.redis.ExceptionTranslationStrategy;
import org.springframework.data.redis.PassThroughExceptionTranslationStrategy;
import org.springframework.data.redis.connection.ReactiveRedisClusterConnection;
import org.springframework.data.redis.connection.ReactiveRedisConnection;
import org.springframework.data.redis.connection.ReactiveRedisConnectionFactory;
import org.springframework.data.redis.connection.RedisClusterConnection;
import org.springframework.data.redis.connection.RedisConnection;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.connection.RedisSentinelConnection;
import org.springframework.data.redis.connection.*;
/**
* Redisson based connection factory
@ -54,12 +48,14 @@ public class RedissonConnectionFactory implements RedisConnectionFactory,
private Config config;
private RedissonClient redisson;
private boolean hasOwnRedisson;
/**
* Creates factory with default Redisson configuration
*/
public RedissonConnectionFactory() {
this(Redisson.create());
hasOwnRedisson = true;
}
/**
@ -79,6 +75,7 @@ public class RedissonConnectionFactory implements RedisConnectionFactory,
public RedissonConnectionFactory(Config config) {
super();
this.config = config;
hasOwnRedisson = true;
}
@Override
@ -88,6 +85,9 @@ public class RedissonConnectionFactory implements RedisConnectionFactory,
@Override
public void destroy() throws Exception {
if (hasOwnRedisson) {
redisson.shutdown();
}
}
@Override

@ -30,13 +30,7 @@ import org.springframework.dao.DataAccessException;
import org.springframework.dao.InvalidDataAccessResourceUsageException;
import org.springframework.data.redis.ExceptionTranslationStrategy;
import org.springframework.data.redis.PassThroughExceptionTranslationStrategy;
import org.springframework.data.redis.connection.ReactiveRedisClusterConnection;
import org.springframework.data.redis.connection.ReactiveRedisConnection;
import org.springframework.data.redis.connection.ReactiveRedisConnectionFactory;
import org.springframework.data.redis.connection.RedisClusterConnection;
import org.springframework.data.redis.connection.RedisConnection;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.connection.RedisSentinelConnection;
import org.springframework.data.redis.connection.*;
/**
* Redisson based connection factory
@ -54,12 +48,14 @@ public class RedissonConnectionFactory implements RedisConnectionFactory,
private Config config;
private RedissonClient redisson;
private boolean hasOwnRedisson;
/**
* Creates factory with default Redisson configuration
*/
public RedissonConnectionFactory() {
this(Redisson.create());
hasOwnRedisson = true;
}
/**
@ -79,6 +75,7 @@ public class RedissonConnectionFactory implements RedisConnectionFactory,
public RedissonConnectionFactory(Config config) {
super();
this.config = config;
hasOwnRedisson = true;
}
@Override
@ -88,6 +85,9 @@ public class RedissonConnectionFactory implements RedisConnectionFactory,
@Override
public void destroy() throws Exception {
if (hasOwnRedisson) {
redisson.shutdown();
}
}
@Override

@ -54,12 +54,14 @@ public class RedissonConnectionFactory implements RedisConnectionFactory,
private Config config;
private RedissonClient redisson;
private boolean hasOwnRedisson;
/**
* Creates factory with default Redisson configuration
*/
public RedissonConnectionFactory() {
this(Redisson.create());
hasOwnRedisson = true;
}
/**
@ -79,6 +81,7 @@ public class RedissonConnectionFactory implements RedisConnectionFactory,
public RedissonConnectionFactory(Config config) {
super();
this.config = config;
hasOwnRedisson = true;
}
@Override
@ -88,6 +91,9 @@ public class RedissonConnectionFactory implements RedisConnectionFactory,
@Override
public void destroy() throws Exception {
if (hasOwnRedisson) {
redisson.shutdown();
}
}
@Override

Loading…
Cancel
Save