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

davsclaus 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 90a4ca746de CAMEL-20767: camel-spring-redis - Creating 
SpringRedisIdempotentRepository via SB should be possible
90a4ca746de is described below

commit 90a4ca746de4c4cae49f1cd59bb8e95e9b751d41
Author: Claus Ibsen <claus.ib...@gmail.com>
AuthorDate: Tue May 14 11:27:23 2024 +0200

    CAMEL-20767: camel-spring-redis - Creating SpringRedisIdempotentRepository 
via SB should be possible
---
 .../processor/idempotent/SpringRedisIdempotentRepository.java    | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git 
a/components/camel-spring-redis/src/main/java/org/apache/camel/component/redis/processor/idempotent/SpringRedisIdempotentRepository.java
 
b/components/camel-spring-redis/src/main/java/org/apache/camel/component/redis/processor/idempotent/SpringRedisIdempotentRepository.java
index 361e1b71943..443df8b0db3 100644
--- 
a/components/camel-spring-redis/src/main/java/org/apache/camel/component/redis/processor/idempotent/SpringRedisIdempotentRepository.java
+++ 
b/components/camel-spring-redis/src/main/java/org/apache/camel/component/redis/processor/idempotent/SpringRedisIdempotentRepository.java
@@ -24,6 +24,7 @@ import org.apache.camel.spi.Configurer;
 import org.apache.camel.spi.IdempotentRepository;
 import org.apache.camel.spi.Metadata;
 import org.apache.camel.support.service.ServiceSupport;
+import org.apache.camel.util.ObjectHelper;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.data.redis.core.SetOperations;
 
@@ -107,10 +108,14 @@ public class SpringRedisIdempotentRepository extends 
ServiceSupport implements I
 
     @Override
     protected void doStart() throws Exception {
-        if (redisConfiguration == null) {
+        if (redisConfiguration == null && this.redisTemplate == null) {
+            // create configuration if no custom template has been configured
             redisConfiguration = new RedisConfiguration();
         }
-        this.redisTemplate = (RedisTemplate<String, String>) 
redisConfiguration.getRedisTemplate();
+        if (this.redisTemplate == null) {
+            this.redisTemplate = (RedisTemplate<String, String>) 
redisConfiguration.getRedisTemplate();
+        }
+        ObjectHelper.notNull(this.redisTemplate, "redisTemplate", this);
         this.setOperations = redisTemplate.opsForSet();
         redisTemplate.getConnectionFactory().getConnection().flushDb();
     }

Reply via email to