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:30:47 UTC

[camel] branch camel-3.18.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.18.x
in repository https://gitbox.apache.org/repos/asf/camel.git


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

commit b4e8049a8a9d55354fff4b3524c27a2b84cd9889
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 3a11ca4b1b7..5db12c99cd7 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
@@ -339,6 +339,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
@@ -350,12 +351,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);