diff --git a/src/main/java/org/springframework/data/redis/connection/RedisConnection.java b/src/main/java/org/springframework/data/redis/connection/RedisConnection.java index 497319f51..b588ae7e5 100644 --- a/src/main/java/org/springframework/data/redis/connection/RedisConnection.java +++ b/src/main/java/org/springframework/data/redis/connection/RedisConnection.java @@ -27,6 +27,7 @@ import org.springframework.dao.DataAccessException; * @author Costin Leau * @author Christoph Strobl * @author Mark Paluch + * @author James Howe */ public interface RedisConnection extends RedisCommands, AutoCloseable { @@ -145,6 +146,7 @@ public interface RedisConnection extends RedisCommands, AutoCloseable { * * @throws DataAccessException */ + @Override void close() throws DataAccessException; /** diff --git a/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceConnectionFactoryUnitTests.java b/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceConnectionFactoryUnitTests.java index f4835277c..e4fb0c4ee 100644 --- a/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceConnectionFactoryUnitTests.java +++ b/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceConnectionFactoryUnitTests.java @@ -52,6 +52,7 @@ import org.springframework.data.redis.ConnectionFactoryTracker; import org.springframework.data.redis.connection.RedisClusterConfiguration; import org.springframework.data.redis.connection.RedisClusterConnection; import org.springframework.data.redis.connection.RedisConfiguration; +import org.springframework.data.redis.connection.RedisConnection; import org.springframework.data.redis.connection.RedisPassword; import org.springframework.data.redis.connection.RedisSentinelConfiguration; import org.springframework.data.redis.connection.RedisSocketConfiguration; @@ -800,7 +801,9 @@ public class LettuceConnectionFactoryUnitTests { connectionFactory.setValidateConnection(true); connectionFactory.afterPropertiesSet(); - connectionFactory.getConnection().close(); + try (RedisConnection connection = connectionFactory.getConnection()) { + connection.ping(); + } verify(syncMock).ping(); }