Skip to content

RedisKeyValueAdapter.destroy calls RedisConnectionFactory.destroy [DATAREDIS-507] #1083

Closed
@spring-projects-issues

Description

@spring-projects-issues

Mark Paluch opened DATAREDIS-507 and commented

The RedisKeyValueAdapter creates an exception during shutdown:

2016-05-03 12:07:02.343  WARN 94337 --- [       Thread-6] o.s.b.f.support.DisposableBeanAdapter    : Invocation of destroy method failed on bean with name 'redisKeyValueAdapter': com.lambdaworks.redis.RedisException: Connection is closed

This is because RedisKeyValueAdapter closes the connection factory before the message listener containers are shut down:

	public void destroy() throws Exception {

		if (redisOps instanceof RedisTemplate) {
			RedisConnectionFactory connectionFactory = ((RedisTemplate<?, ?>) redisOps).getConnectionFactory();
			if (connectionFactory instanceof DisposableBean) {
				((DisposableBean) connectionFactory).destroy();
			}
		}

		this.expirationListener.destroy();
		this.messageListenerContainer.destroy();
	}

Closing the RedisConnectionFactory seems not necessary as the bean is managed by the container itself


Reference URL: https://github.com/spring-projects/spring-data-redis/blob/master/src/main/java/org/springframework/data/redis/core/RedisKeyValueAdapter.java#L450

Referenced from: pull request #195

Backported to: 1.7.2 (Hopper SR2)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions