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

fmariani 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 f5777efd2d2a Guard LRU cache creation against maxCacheSize <= 0
f5777efd2d2a is described below

commit f5777efd2d2a0cf6848660f94200b118b88f715f
Author: Croway <[email protected]>
AuthorDate: Tue Feb 10 14:39:35 2026 +0100

    Guard LRU cache creation against maxCacheSize <= 0
---
 .../org/apache/camel/catalog/beans/KafkaIdempotentRepository.json | 2 +-
 .../resources/org/apache/camel/catalog/components/cxfrs.json      | 2 +-
 .../META-INF/org/apache/camel/component/cxf/jaxrs/cxfrs.json      | 2 +-
 .../java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java  | 8 +++++++-
 .../services/org/apache/camel/bean/KafkaIdempotentRepository.json | 2 +-
 .../processor/idempotent/kafka/KafkaIdempotentRepository.java     | 6 +++++-
 .../org/apache/camel/impl/engine/AbstractDynamicRegistry.java     | 3 +++
 .../apache/camel/impl/engine/DefaultRuntimeEndpointRegistry.java  | 3 +++
 .../camel/support/DefaultEndpointUtilizationStatistics.java       | 3 +++
 .../support/processor/idempotent/FileIdempotentRepository.java    | 6 ++++++
 .../camel/builder/endpoint/dsl/CxfRsEndpointBuilderFactory.java   | 4 ++--
 11 files changed, 33 insertions(+), 8 deletions(-)

diff --git 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/beans/KafkaIdempotentRepository.json
 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/beans/KafkaIdempotentRepository.json
index f08c7d802aff..fc039db8573f 100644
--- 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/beans/KafkaIdempotentRepository.json
+++ 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/beans/KafkaIdempotentRepository.json
@@ -10,7 +10,7 @@
     "groupId": "org.apache.camel",
     "artifactId": "camel-kafka",
     "version": "4.18.0-SNAPSHOT",
-    "properties": { "topic": { "index": 0, "kind": "property", "displayName": 
"Topic", "required": true, "type": "string", "javaType": "java.lang.String", 
"deprecated": false, "autowired": false, "secret": false, "description": "Sets 
the name of the Kafka topic used by this idempotent repository. Each 
functionally-separate repository should use a different topic." }, 
"bootstrapServers": { "index": 1, "kind": "property", "displayName": "Bootstrap 
Servers", "required": true, "type": "strin [...]
+    "properties": { "topic": { "index": 0, "kind": "property", "displayName": 
"Topic", "required": true, "type": "string", "javaType": "java.lang.String", 
"deprecated": false, "autowired": false, "secret": false, "description": "Sets 
the name of the Kafka topic used by this idempotent repository. Each 
functionally-separate repository should use a different topic." }, 
"bootstrapServers": { "index": 1, "kind": "property", "displayName": "Bootstrap 
Servers", "required": true, "type": "strin [...]
   }
 }
 
diff --git 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/cxfrs.json
 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/cxfrs.json
index d635cc16b024..7cddf424f748 100644
--- 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/cxfrs.json
+++ 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/cxfrs.json
@@ -72,7 +72,7 @@
     "httpClientAPI": { "index": 18, "kind": "parameter", "displayName": "Http 
Client API", "group": "producer (advanced)", "label": "producer,advanced", 
"required": false, "type": "boolean", "javaType": "boolean", "deprecated": 
false, "autowired": false, "secret": false, "defaultValue": true, 
"description": "If it is true, the CxfRsProducer will use the HttpClientAPI to 
invoke the service. If it is false, the CxfRsProducer will use the 
ProxyClientAPI to invoke the service" },
     "ignoreDeleteMethodMessageBody": { "index": 19, "kind": "parameter", 
"displayName": "Ignore Delete Method Message Body", "group": "producer 
(advanced)", "label": "producer,advanced", "required": false, "type": 
"boolean", "javaType": "boolean", "deprecated": false, "autowired": false, 
"secret": false, "defaultValue": false, "description": "This option is used to 
tell CxfRsProducer to ignore the message body of the DELETE method when using 
HTTP API." },
     "lazyStartProducer": { "index": 20, "kind": "parameter", "displayName": 
"Lazy Start Producer", "group": "producer (advanced)", "label": 
"producer,advanced", "required": false, "type": "boolean", "javaType": 
"boolean", "deprecated": false, "autowired": false, "secret": false, 
"defaultValue": false, "description": "Whether the producer should be started 
lazy (on the first message). By starting lazy you can use this to allow 
CamelContext and routes to startup in situations where a produ [...]
-    "maxClientCacheSize": { "index": 21, "kind": "parameter", "displayName": 
"Max Client Cache Size", "group": "producer (advanced)", "label": 
"producer,advanced", "required": false, "type": "integer", "javaType": "int", 
"deprecated": false, "autowired": false, "secret": false, "defaultValue": 10, 
"description": "This option allows you to configure the maximum size of the 
cache. The implementation caches CXF clients or ClientFactoryBean in 
CxfProvider and CxfRsProvider." },
+    "maxClientCacheSize": { "index": 21, "kind": "parameter", "displayName": 
"Max Client Cache Size", "group": "producer (advanced)", "label": 
"producer,advanced", "required": false, "type": "integer", "javaType": "int", 
"deprecated": false, "autowired": false, "secret": false, "defaultValue": 10, 
"description": "This option allows you to configure the maximum size of the 
cache. The implementation caches CXF clients or ClientFactoryBean in 
CxfProvider and CxfRsProvider. The value must be [...]
     "synchronous": { "index": 22, "kind": "parameter", "displayName": 
"Synchronous", "group": "producer (advanced)", "label": "producer,advanced", 
"required": false, "type": "boolean", "javaType": "boolean", "deprecated": 
false, "autowired": false, "secret": false, "defaultValue": false, 
"description": "Sets whether synchronous processing should be strictly used" },
     "binding": { "index": 23, "kind": "parameter", "displayName": "Binding", 
"group": "advanced", "label": "advanced", "required": false, "type": "object", 
"javaType": "org.apache.camel.component.cxf.jaxrs.CxfRsBinding", "deprecated": 
false, "autowired": false, "secret": false, "description": "To use a custom 
CxfBinding to control the binding between Camel Message and CXF Message." },
     "bus": { "index": 24, "kind": "parameter", "displayName": "Bus", "group": 
"advanced", "label": "advanced", "required": false, "type": "object", 
"javaType": "org.apache.cxf.Bus", "deprecated": false, "autowired": false, 
"secret": false, "description": "To use a custom configured CXF Bus." },
diff --git 
a/components/camel-cxf/camel-cxf-rest/src/generated/resources/META-INF/org/apache/camel/component/cxf/jaxrs/cxfrs.json
 
b/components/camel-cxf/camel-cxf-rest/src/generated/resources/META-INF/org/apache/camel/component/cxf/jaxrs/cxfrs.json
index d635cc16b024..7cddf424f748 100644
--- 
a/components/camel-cxf/camel-cxf-rest/src/generated/resources/META-INF/org/apache/camel/component/cxf/jaxrs/cxfrs.json
+++ 
b/components/camel-cxf/camel-cxf-rest/src/generated/resources/META-INF/org/apache/camel/component/cxf/jaxrs/cxfrs.json
@@ -72,7 +72,7 @@
     "httpClientAPI": { "index": 18, "kind": "parameter", "displayName": "Http 
Client API", "group": "producer (advanced)", "label": "producer,advanced", 
"required": false, "type": "boolean", "javaType": "boolean", "deprecated": 
false, "autowired": false, "secret": false, "defaultValue": true, 
"description": "If it is true, the CxfRsProducer will use the HttpClientAPI to 
invoke the service. If it is false, the CxfRsProducer will use the 
ProxyClientAPI to invoke the service" },
     "ignoreDeleteMethodMessageBody": { "index": 19, "kind": "parameter", 
"displayName": "Ignore Delete Method Message Body", "group": "producer 
(advanced)", "label": "producer,advanced", "required": false, "type": 
"boolean", "javaType": "boolean", "deprecated": false, "autowired": false, 
"secret": false, "defaultValue": false, "description": "This option is used to 
tell CxfRsProducer to ignore the message body of the DELETE method when using 
HTTP API." },
     "lazyStartProducer": { "index": 20, "kind": "parameter", "displayName": 
"Lazy Start Producer", "group": "producer (advanced)", "label": 
"producer,advanced", "required": false, "type": "boolean", "javaType": 
"boolean", "deprecated": false, "autowired": false, "secret": false, 
"defaultValue": false, "description": "Whether the producer should be started 
lazy (on the first message). By starting lazy you can use this to allow 
CamelContext and routes to startup in situations where a produ [...]
-    "maxClientCacheSize": { "index": 21, "kind": "parameter", "displayName": 
"Max Client Cache Size", "group": "producer (advanced)", "label": 
"producer,advanced", "required": false, "type": "integer", "javaType": "int", 
"deprecated": false, "autowired": false, "secret": false, "defaultValue": 10, 
"description": "This option allows you to configure the maximum size of the 
cache. The implementation caches CXF clients or ClientFactoryBean in 
CxfProvider and CxfRsProvider." },
+    "maxClientCacheSize": { "index": 21, "kind": "parameter", "displayName": 
"Max Client Cache Size", "group": "producer (advanced)", "label": 
"producer,advanced", "required": false, "type": "integer", "javaType": "int", 
"deprecated": false, "autowired": false, "secret": false, "defaultValue": 10, 
"description": "This option allows you to configure the maximum size of the 
cache. The implementation caches CXF clients or ClientFactoryBean in 
CxfProvider and CxfRsProvider. The value must be [...]
     "synchronous": { "index": 22, "kind": "parameter", "displayName": 
"Synchronous", "group": "producer (advanced)", "label": "producer,advanced", 
"required": false, "type": "boolean", "javaType": "boolean", "deprecated": 
false, "autowired": false, "secret": false, "defaultValue": false, 
"description": "Sets whether synchronous processing should be strictly used" },
     "binding": { "index": 23, "kind": "parameter", "displayName": "Binding", 
"group": "advanced", "label": "advanced", "required": false, "type": "object", 
"javaType": "org.apache.camel.component.cxf.jaxrs.CxfRsBinding", "deprecated": 
false, "autowired": false, "secret": false, "description": "To use a custom 
CxfBinding to control the binding between Camel Message and CXF Message." },
     "bus": { "index": 24, "kind": "parameter", "displayName": "Bus", "group": 
"advanced", "label": "advanced", "required": false, "type": "object", 
"javaType": "org.apache.cxf.Bus", "deprecated": false, "autowired": false, 
"secret": false, "description": "To use a custom configured CXF Bus." },
diff --git 
a/components/camel-cxf/camel-cxf-rest/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java
 
b/components/camel-cxf/camel-cxf-rest/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java
index 1b3dadd8a27e..aa1d9e2c8ba9 100644
--- 
a/components/camel-cxf/camel-cxf-rest/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java
+++ 
b/components/camel-cxf/camel-cxf-rest/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java
@@ -120,7 +120,10 @@ public class CxfRsEndpoint extends DefaultEndpoint 
implements HeaderFilterStrate
     private boolean ignoreDeleteMethodMessageBody;
     @UriParam(label = "producer", defaultValue = "true")
     private boolean throwExceptionOnFailure = true;
-    @UriParam(label = "producer,advanced", defaultValue = "10")
+    @UriParam(label = "producer,advanced", defaultValue = "10",
+              description = "This option allows you to configure the maximum 
size of the cache."
+                            + " The implementation caches CXF clients or 
ClientFactoryBean in CxfProvider and CxfRsProvider."
+                            + " The value must be greater than 0.")
     private int maxClientCacheSize = 10;
     @UriParam(label = "producer")
     private SSLContextParameters sslContextParameters;
@@ -573,6 +576,9 @@ public class CxfRsEndpoint extends DefaultEndpoint 
implements HeaderFilterStrate
      * ClientFactoryBean in CxfProvider and CxfRsProvider.
      */
     public void setMaxClientCacheSize(int maxClientCacheSize) {
+        if (maxClientCacheSize <= 0) {
+            throw new IllegalArgumentException("maxClientCacheSize must be 
greater than 0, was: " + maxClientCacheSize);
+        }
         this.maxClientCacheSize = maxClientCacheSize;
     }
 
diff --git 
a/components/camel-kafka/src/generated/resources/META-INF/services/org/apache/camel/bean/KafkaIdempotentRepository.json
 
b/components/camel-kafka/src/generated/resources/META-INF/services/org/apache/camel/bean/KafkaIdempotentRepository.json
index f08c7d802aff..fc039db8573f 100644
--- 
a/components/camel-kafka/src/generated/resources/META-INF/services/org/apache/camel/bean/KafkaIdempotentRepository.json
+++ 
b/components/camel-kafka/src/generated/resources/META-INF/services/org/apache/camel/bean/KafkaIdempotentRepository.json
@@ -10,7 +10,7 @@
     "groupId": "org.apache.camel",
     "artifactId": "camel-kafka",
     "version": "4.18.0-SNAPSHOT",
-    "properties": { "topic": { "index": 0, "kind": "property", "displayName": 
"Topic", "required": true, "type": "string", "javaType": "java.lang.String", 
"deprecated": false, "autowired": false, "secret": false, "description": "Sets 
the name of the Kafka topic used by this idempotent repository. Each 
functionally-separate repository should use a different topic." }, 
"bootstrapServers": { "index": 1, "kind": "property", "displayName": "Bootstrap 
Servers", "required": true, "type": "strin [...]
+    "properties": { "topic": { "index": 0, "kind": "property", "displayName": 
"Topic", "required": true, "type": "string", "javaType": "java.lang.String", 
"deprecated": false, "autowired": false, "secret": false, "description": "Sets 
the name of the Kafka topic used by this idempotent repository. Each 
functionally-separate repository should use a different topic." }, 
"bootstrapServers": { "index": 1, "kind": "property", "displayName": "Bootstrap 
Servers", "required": true, "type": "strin [...]
   }
 }
 
diff --git 
a/components/camel-kafka/src/main/java/org/apache/camel/processor/idempotent/kafka/KafkaIdempotentRepository.java
 
b/components/camel-kafka/src/main/java/org/apache/camel/processor/idempotent/kafka/KafkaIdempotentRepository.java
index 6a9e05db1160..79f59508a977 100644
--- 
a/components/camel-kafka/src/main/java/org/apache/camel/processor/idempotent/kafka/KafkaIdempotentRepository.java
+++ 
b/components/camel-kafka/src/main/java/org/apache/camel/processor/idempotent/kafka/KafkaIdempotentRepository.java
@@ -106,7 +106,8 @@ public class KafkaIdempotentRepository extends 
ServiceSupport implements Idempot
     @Metadata(description = "A string that uniquely identifies the group of 
consumer processes to which this consumer belongs. By setting the"
                             + " same group id, multiple processes can indicate 
that they are all part of the same consumer group.")
     private String groupId;
-    @Metadata(description = "Sets the maximum size of the local key cache.", 
defaultValue = "" + DEFAULT_MAXIMUM_CACHE_SIZE)
+    @Metadata(description = "Sets the maximum size of the local key cache. The 
value must be greater than 0.",
+              defaultValue = "" + DEFAULT_MAXIMUM_CACHE_SIZE)
     private int maxCacheSize = DEFAULT_MAXIMUM_CACHE_SIZE;
     @Metadata(description = "Sets the poll duration of the Kafka consumer. The 
local caches are updated immediately; this value will affect"
                             + " how far behind other peers in the cluster are, 
which are updating their caches from the topic, relative to the"
@@ -273,6 +274,9 @@ public class KafkaIdempotentRepository extends 
ServiceSupport implements Idempot
      * @param maxCacheSize The maximum key cache size.
      */
     public void setMaxCacheSize(int maxCacheSize) {
+        if (maxCacheSize <= 0) {
+            throw new IllegalArgumentException("maxCacheSize must be greater 
than 0, was: " + maxCacheSize);
+        }
         this.maxCacheSize = maxCacheSize;
     }
 
diff --git 
a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractDynamicRegistry.java
 
b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractDynamicRegistry.java
index a6e93b1ce93c..0ddf89a44986 100644
--- 
a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractDynamicRegistry.java
+++ 
b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractDynamicRegistry.java
@@ -49,6 +49,9 @@ public class AbstractDynamicRegistry<K, V> extends 
AbstractMap<K, V> implements
     protected final Map<K, V> staticMap;
 
     public AbstractDynamicRegistry(CamelContext context, int maxCacheSize) {
+        if (maxCacheSize <= 0) {
+            throw new IllegalArgumentException("maxCacheSize must be greater 
than 0");
+        }
         this.context = context;
         this.routeController = context.getRouteController();
         this.maxCacheSize = maxCacheSize;
diff --git 
a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultRuntimeEndpointRegistry.java
 
b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultRuntimeEndpointRegistry.java
index e49217d5ec13..691992ba4e4b 100644
--- 
a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultRuntimeEndpointRegistry.java
+++ 
b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultRuntimeEndpointRegistry.java
@@ -221,6 +221,9 @@ public class DefaultRuntimeEndpointRegistry extends 
EventNotifierSupport impleme
             inputs.put(routeId, uris);
             // use a LRUCache for outputs as we could potential have unlimited 
uris if dynamic routing is in use
             // and therefore need to have the limit in use
+            if (limit <= 0) {
+                throw new IllegalArgumentException("limit must be greater than 
0");
+            }
             outputs.put(routeId, LRUCacheFactory.newLRUCache(limit));
         } else if (event instanceof RouteRemovedEvent rse) {
             String routeId = rse.getRoute().getId();
diff --git 
a/core/camel-support/src/main/java/org/apache/camel/support/DefaultEndpointUtilizationStatistics.java
 
b/core/camel-support/src/main/java/org/apache/camel/support/DefaultEndpointUtilizationStatistics.java
index d17d1e281308..c9c3cedb9de2 100644
--- 
a/core/camel-support/src/main/java/org/apache/camel/support/DefaultEndpointUtilizationStatistics.java
+++ 
b/core/camel-support/src/main/java/org/apache/camel/support/DefaultEndpointUtilizationStatistics.java
@@ -30,6 +30,9 @@ public class DefaultEndpointUtilizationStatistics implements 
EndpointUtilization
     private final Lock lock = new ReentrantLock();
 
     public DefaultEndpointUtilizationStatistics(int maxCapacity) {
+        if (maxCapacity <= 0) {
+            throw new IllegalArgumentException("maxCapacity must be greater 
than 0");
+        }
         this.map = LRUCacheFactory.newLRUCache(16, maxCapacity, false);
         this.maxCapacity = maxCapacity;
     }
diff --git 
a/core/camel-support/src/main/java/org/apache/camel/support/processor/idempotent/FileIdempotentRepository.java
 
b/core/camel-support/src/main/java/org/apache/camel/support/processor/idempotent/FileIdempotentRepository.java
index 93bfa3cbf8eb..81cbfc2a6b6d 100644
--- 
a/core/camel-support/src/main/java/org/apache/camel/support/processor/idempotent/FileIdempotentRepository.java
+++ 
b/core/camel-support/src/main/java/org/apache/camel/support/processor/idempotent/FileIdempotentRepository.java
@@ -106,6 +106,9 @@ public class FileIdempotentRepository extends 
ServiceSupport implements Idempote
      * @param cacheSize the cache size
      */
     public static IdempotentRepository fileIdempotentRepository(File 
fileStore, int cacheSize) {
+        if (cacheSize <= 0) {
+            throw new IllegalArgumentException("cacheSize must be greater than 
0, was: " + cacheSize);
+        }
         return fileIdempotentRepository(fileStore, 
LRUCacheFactory.newLRUCache(cacheSize));
     }
 
@@ -117,6 +120,9 @@ public class FileIdempotentRepository extends 
ServiceSupport implements Idempote
      * @param maxFileStoreSize the max size in bytes for the filestore file
      */
     public static IdempotentRepository fileIdempotentRepository(File 
fileStore, int cacheSize, long maxFileStoreSize) {
+        if (cacheSize <= 0) {
+            throw new IllegalArgumentException("cacheSize must be greater than 
0, was: " + cacheSize);
+        }
         FileIdempotentRepository repository = new 
FileIdempotentRepository(fileStore, LRUCacheFactory.newLRUCache(cacheSize));
         repository.setMaxFileStoreSize(maxFileStoreSize);
         return repository;
diff --git 
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/CxfRsEndpointBuilderFactory.java
 
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/CxfRsEndpointBuilderFactory.java
index 6809d5d46be4..28a6350b88ff 100644
--- 
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/CxfRsEndpointBuilderFactory.java
+++ 
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/CxfRsEndpointBuilderFactory.java
@@ -1240,7 +1240,7 @@ public interface CxfRsEndpointBuilderFactory {
         /**
          * This option allows you to configure the maximum size of the cache.
          * The implementation caches CXF clients or ClientFactoryBean in
-         * CxfProvider and CxfRsProvider.
+         * CxfProvider and CxfRsProvider. The value must be greater than 0.
          * 
          * The option is a: <code>int</code> type.
          * 
@@ -1257,7 +1257,7 @@ public interface CxfRsEndpointBuilderFactory {
         /**
          * This option allows you to configure the maximum size of the cache.
          * The implementation caches CXF clients or ClientFactoryBean in
-         * CxfProvider and CxfRsProvider.
+         * CxfProvider and CxfRsProvider. The value must be greater than 0.
          * 
          * The option will be converted to a <code>int</code> type.
          * 

Reply via email to