This is an automated email from the ASF dual-hosted git repository.

apupier pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new af85e87f805e Replace deprecated methods in redis component
af85e87f805e is described below

commit af85e87f805ecf081de911767af389cd4c49d142
Author: AurĂ©lien Pupier <[email protected]>
AuthorDate: Tue Jun 2 11:03:38 2026 +0200

    Replace deprecated methods in redis component
    
    Signed-off-by: AurĂ©lien Pupier <[email protected]>
---
 .../src/main/java/org/apache/camel/component/redis/RedisClient.java | 4 ++--
 .../redis/processor/idempotent/SpringRedisIdempotentRepository.java | 4 ++--
 .../processor/idempotent/SpringRedisStringIdempotentRepository.java | 5 +++--
 .../processor/idempotent/SpringRedisIdempotentRepositoryTest.java   | 6 +++++-
 4 files changed, 12 insertions(+), 7 deletions(-)

diff --git 
a/components/camel-spring-parent/camel-spring-redis/src/main/java/org/apache/camel/component/redis/RedisClient.java
 
b/components/camel-spring-parent/camel-spring-redis/src/main/java/org/apache/camel/component/redis/RedisClient.java
index f88487036413..1af198763655 100644
--- 
a/components/camel-spring-parent/camel-spring-redis/src/main/java/org/apache/camel/component/redis/RedisClient.java
+++ 
b/components/camel-spring-parent/camel-spring-redis/src/main/java/org/apache/camel/component/redis/RedisClient.java
@@ -158,14 +158,14 @@ public class RedisClient {
 
     public void setbit(final String key, final Long offset, final Boolean 
value) {
         redisTemplate.execute((RedisCallback<Object>) connection -> {
-            connection.setBit(key.getBytes(), offset, value);
+            connection.stringCommands().setBit(key.getBytes(), offset, value);
             return null;
         });
     }
 
     public Boolean getbit(final String key, final Long offset) {
         return redisTemplate.execute((RedisCallback<Boolean>) connection -> {
-            return connection.getBit(key.getBytes(), offset);
+            return connection.stringCommands().getBit(key.getBytes(), offset);
         });
     }
 
diff --git 
a/components/camel-spring-parent/camel-spring-redis/src/main/java/org/apache/camel/component/redis/processor/idempotent/SpringRedisIdempotentRepository.java
 
b/components/camel-spring-parent/camel-spring-redis/src/main/java/org/apache/camel/component/redis/processor/idempotent/SpringRedisIdempotentRepository.java
index bd74366b3697..6b5bb1f205b9 100644
--- 
a/components/camel-spring-parent/camel-spring-redis/src/main/java/org/apache/camel/component/redis/processor/idempotent/SpringRedisIdempotentRepository.java
+++ 
b/components/camel-spring-parent/camel-spring-redis/src/main/java/org/apache/camel/component/redis/processor/idempotent/SpringRedisIdempotentRepository.java
@@ -104,7 +104,7 @@ public class SpringRedisIdempotentRepository extends 
ServiceSupport implements I
     @Override
     @ManagedOperation(description = "Clear the store")
     public void clear() {
-        redisTemplate.getConnectionFactory().getConnection().flushDb();
+        
redisTemplate.getConnectionFactory().getConnection().serverCommands().flushDb();
     }
 
     public void setRepositoryName(String repositoryName) {
@@ -133,7 +133,7 @@ public class SpringRedisIdempotentRepository extends 
ServiceSupport implements I
         ObjectHelper.notNull(this.redisTemplate, "redisTemplate", this);
         this.setOperations = redisTemplate.opsForSet();
         if (flushOnStartup) {
-            redisTemplate.getConnectionFactory().getConnection().flushDb();
+            
redisTemplate.getConnectionFactory().getConnection().serverCommands().flushDb();
         }
     }
 
diff --git 
a/components/camel-spring-parent/camel-spring-redis/src/main/java/org/apache/camel/component/redis/processor/idempotent/SpringRedisStringIdempotentRepository.java
 
b/components/camel-spring-parent/camel-spring-redis/src/main/java/org/apache/camel/component/redis/processor/idempotent/SpringRedisStringIdempotentRepository.java
index 647d33658865..ab4e5fcfada1 100644
--- 
a/components/camel-spring-parent/camel-spring-redis/src/main/java/org/apache/camel/component/redis/processor/idempotent/SpringRedisStringIdempotentRepository.java
+++ 
b/components/camel-spring-parent/camel-spring-redis/src/main/java/org/apache/camel/component/redis/processor/idempotent/SpringRedisStringIdempotentRepository.java
@@ -72,14 +72,15 @@ public class SpringRedisStringIdempotentRepository extends 
SpringRedisIdempotent
             @Override
             public List<byte[]> doInRedis(RedisConnection connection) throws 
DataAccessException {
                 List<byte[]> binaryKeys = new ArrayList<>();
-                Cursor<byte[]> cursor = 
connection.scan(ScanOptions.scanOptions().match("*" + 
createRedisKey("*")).build());
+                Cursor<byte[]> cursor
+                        = 
connection.keyCommands().scan(ScanOptions.scanOptions().match("*" + 
createRedisKey("*")).build());
 
                 while (cursor.hasNext()) {
                     byte[] key = cursor.next();
                     binaryKeys.add(key);
                 }
                 if (!binaryKeys.isEmpty()) {
-                    connection.del(binaryKeys.toArray(new byte[][] {}));
+                    connection.keyCommands().del(binaryKeys.toArray(new 
byte[][] {}));
                 }
                 return binaryKeys;
             }
diff --git 
a/components/camel-spring-parent/camel-spring-redis/src/test/java/org/apache/camel/component/redis/processor/idempotent/SpringRedisIdempotentRepositoryTest.java
 
b/components/camel-spring-parent/camel-spring-redis/src/test/java/org/apache/camel/component/redis/processor/idempotent/SpringRedisIdempotentRepositoryTest.java
index f2fe5aa2f3eb..31c635ce7ece 100644
--- 
a/components/camel-spring-parent/camel-spring-redis/src/test/java/org/apache/camel/component/redis/processor/idempotent/SpringRedisIdempotentRepositoryTest.java
+++ 
b/components/camel-spring-parent/camel-spring-redis/src/test/java/org/apache/camel/component/redis/processor/idempotent/SpringRedisIdempotentRepositoryTest.java
@@ -23,6 +23,7 @@ import org.mockito.junit.jupiter.MockitoSettings;
 import org.mockito.quality.Strictness;
 import org.springframework.data.redis.connection.RedisConnection;
 import org.springframework.data.redis.connection.RedisConnectionFactory;
+import org.springframework.data.redis.connection.RedisServerCommands;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.data.redis.core.SetOperations;
 
@@ -44,6 +45,8 @@ public class SpringRedisIdempotentRepositoryTest {
     private RedisConnection redisConnection;
     @Mock
     private SetOperations<String, String> setOperations;
+    @Mock
+    private RedisServerCommands redisServerCommands;
 
     private SpringRedisIdempotentRepository idempotentRepository;
 
@@ -52,6 +55,7 @@ public class SpringRedisIdempotentRepositoryTest {
         when(redisTemplate.opsForSet()).thenReturn(setOperations);
         
when(redisTemplate.getConnectionFactory()).thenReturn(redisConnectionFactory);
         
when(redisTemplate.getConnectionFactory().getConnection()).thenReturn(redisConnection);
+        when(redisConnection.serverCommands()).thenReturn(redisServerCommands);
         idempotentRepository = 
SpringRedisIdempotentRepository.redisIdempotentRepository(redisTemplate, 
REPOSITORY);
     }
 
@@ -76,7 +80,7 @@ public class SpringRedisIdempotentRepositoryTest {
     @Test
     public void shouldClearRepository() {
         idempotentRepository.clear();
-        verify(redisConnection).flushDb();
+        verify(redisConnection.serverCommands()).flushDb();
     }
 
     @Test

Reply via email to