You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2023/02/09 08:31:02 UTC

[camel] branch camel-3.14.x updated: CAMEL-19014: Disabling simple cache with 0 or negative value should be possible

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

davsclaus pushed a commit to branch camel-3.14.x
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/camel-3.14.x by this push:
     new c922d557a70 CAMEL-19014: Disabling simple cache with 0 or negative value should be possible
c922d557a70 is described below

commit c922d557a7077b15f5d622def9bf8ccd9790031d
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Thu Feb 9 09:28:23 2023 +0100

    CAMEL-19014: Disabling simple cache with 0 or negative value should be possible
---
 .../main/java/org/apache/camel/support/CamelContextHelper.java    | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/core/camel-support/src/main/java/org/apache/camel/support/CamelContextHelper.java b/core/camel-support/src/main/java/org/apache/camel/support/CamelContextHelper.java
index aef017586fb..c73b9c4bc98 100644
--- a/core/camel-support/src/main/java/org/apache/camel/support/CamelContextHelper.java
+++ b/core/camel-support/src/main/java/org/apache/camel/support/CamelContextHelper.java
@@ -344,6 +344,7 @@ public final class CamelContextHelper {
      * <p/>
      * Will use the property set on CamelContext with the key {@link Exchange#MAXIMUM_SIMPLE_CACHE_SIZE}. If no property
      * has been set, then it will fallback to return a size of 1000.
+     * Use value of 0 or negative to disable the cache.
      *
      * @param  camelContext             the camel context
      * @return                          the maximum cache size
@@ -355,12 +356,7 @@ public final class CamelContextHelper {
             if (s != null) {
                 // we cannot use Camel type converters as they may not be ready this early
                 try {
-                    Integer size = Integer.valueOf(s);
-                    if (size == null || size <= 0) {
-                        throw new IllegalArgumentException(
-                                "Property " + Exchange.MAXIMUM_SIMPLE_CACHE_SIZE + " must be a positive number, was: " + s);
-                    }
-                    return size;
+                    return Integer.parseInt(s);
                 } catch (NumberFormatException e) {
                     throw new IllegalArgumentException(
                             "Property " + Exchange.MAXIMUM_SIMPLE_CACHE_SIZE + " must be a positive number, was: " + s, e);