diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/redis/RedisHealthIndicator.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/redis/RedisHealthIndicator.java index 63486870c2..86f5690ac4 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/redis/RedisHealthIndicator.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/redis/RedisHealthIndicator.java @@ -60,7 +60,7 @@ public class RedisHealthIndicator extends AbstractHealthIndicator { RedisHealth.fromClusterInfo(builder, ((RedisClusterConnection) connection).clusterGetClusterInfo()); } else { - RedisHealth.up(builder, connection.info("server")); + RedisHealth.up(builder, connection.serverCommands().info()); } } diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/redis/RedisHealthIndicatorTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/redis/RedisHealthIndicatorTests.java index 564f68e070..790f104564 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/redis/RedisHealthIndicatorTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/redis/RedisHealthIndicatorTests.java @@ -30,6 +30,7 @@ import org.springframework.data.redis.connection.RedisClusterConnection; import org.springframework.data.redis.connection.RedisClusterNode; import org.springframework.data.redis.connection.RedisConnection; import org.springframework.data.redis.connection.RedisConnectionFactory; +import org.springframework.data.redis.connection.RedisServerCommands; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.BDDMockito.given; @@ -51,7 +52,9 @@ class RedisHealthIndicatorTests { Properties info = new Properties(); info.put("redis_version", "2.8.9"); RedisConnection redisConnection = mock(RedisConnection.class); - given(redisConnection.info("server")).willReturn(info); + RedisServerCommands serverCommands = mock(RedisServerCommands.class); + given(redisConnection.serverCommands()).willReturn(serverCommands); + given(serverCommands.info()).willReturn(info); RedisHealthIndicator healthIndicator = createHealthIndicator(redisConnection); Health health = healthIndicator.health(); assertThat(health.getStatus()).isEqualTo(Status.UP); @@ -61,7 +64,9 @@ class RedisHealthIndicatorTests { @Test void redisIsDown() { RedisConnection redisConnection = mock(RedisConnection.class); - given(redisConnection.info("server")).willThrow(new RedisConnectionFailureException("Connection failed")); + RedisServerCommands serverCommands = mock(RedisServerCommands.class); + given(redisConnection.serverCommands()).willReturn(serverCommands); + given(serverCommands.info()).willThrow(new RedisConnectionFailureException("Connection failed")); RedisHealthIndicator healthIndicator = createHealthIndicator(redisConnection); Health health = healthIndicator.health(); assertThat(health.getStatus()).isEqualTo(Status.DOWN); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/SessionAutoConfigurationRedisTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/SessionAutoConfigurationRedisTests.java index 418fd7f88b..2fd786ae7b 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/SessionAutoConfigurationRedisTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/SessionAutoConfigurationRedisTests.java @@ -158,7 +158,7 @@ class SessionAutoConfigurationRedisTests extends AbstractSessionAutoConfiguratio assertThat(context.getBean(ConfigureRedisAction.class)).isInstanceOf(expectedConfigureRedisActionType); RedisConnection connection = context.getBean(RedisConnectionFactory.class).getConnection(); if (expectedConfig.length > 0) { - assertThat(connection.getConfig("*")).contains(expectedConfig); + assertThat(connection.serverCommands().getConfig("*")).contains(expectedConfig); } }; } @@ -167,7 +167,7 @@ class SessionAutoConfigurationRedisTests extends AbstractSessionAutoConfiguratio @Override public void configure(RedisConnection connection) { - connection.setConfig("set-max-intset-entries", "1024"); + connection.serverCommands().setConfig("set-max-intset-entries", "1024"); } } diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestIntegrationTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestIntegrationTests.java index ef7d4b19a6..7871e3a94a 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestIntegrationTests.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -71,7 +71,7 @@ class DataRedisTestIntegrationTests { assertThat(personHash.getId()).isNull(); PersonHash savedEntity = this.exampleRepository.save(personHash); assertThat(savedEntity.getId()).isNotNull(); - assertThat(this.operations.execute((RedisConnection connection) -> connection + assertThat(this.operations.execute((RedisConnection connection) -> connection.keyCommands() .exists(("persons:" + savedEntity.getId()).getBytes(CHARSET)))).isTrue(); this.exampleRepository.deleteAll(); } diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/ExampleService.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/ExampleService.java index 284bf4cd9e..3b05e4720d 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/ExampleService.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/ExampleService.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,8 +40,8 @@ public class ExampleService { } public boolean hasRecord(PersonHash personHash) { - return this.operations.execute( - (RedisConnection connection) -> connection.exists(("persons:" + personHash.getId()).getBytes(CHARSET))); + return this.operations.execute((RedisConnection connection) -> connection.keyCommands() + .exists(("persons:" + personHash.getId()).getBytes(CHARSET))); } }