You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by or...@apache.org on 2024/08/22 07:56:06 UTC
(camel) 01/02: (chores) Adjust the IOHelper to use the same buffer size as OpenJDK
This is an automated email from the ASF dual-hosted git repository.
orpiske pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 36f06ebcaef3e6728ace167812b9970c71f3bd37
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Tue Aug 20 14:12:59 2024 +0200
(chores) Adjust the IOHelper to use the same buffer size as OpenJDK
---
.../resources/org/apache/camel/catalog/schemas/camel-spring.xsd | 2 +-
.../apache/camel/spring/processor/SpringStreamCachingStrategyTest.java | 3 ++-
.../resources/META-INF/org/apache/camel/core/xml/streamCaching.json | 2 +-
core/camel-util/src/main/java/org/apache/camel/util/IOHelper.java | 3 ++-
4 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-spring.xsd b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-spring.xsd
index 82642faec57..c7af2c9d48f 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-spring.xsd
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-spring.xsd
@@ -3308,7 +3308,7 @@ separated by comma.
<xs:documentation xml:lang="en">
<![CDATA[
Sets the buffer size to use when allocating in-memory buffers used for in-memory stream caches. The default size is
-org.apache.camel.util.IOHelper#DEFAULT_BUFFER_SIZE. Default value: 4096
+org.apache.camel.util.IOHelper#DEFAULT_BUFFER_SIZE. Default value: 16384
]]>
</xs:documentation>
</xs:annotation>
diff --git a/components/camel-spring-xml/src/test/java/org/apache/camel/spring/processor/SpringStreamCachingStrategyTest.java b/components/camel-spring-xml/src/test/java/org/apache/camel/spring/processor/SpringStreamCachingStrategyTest.java
index 9b00b47a6b1..40ba7eb67d2 100644
--- a/components/camel-spring-xml/src/test/java/org/apache/camel/spring/processor/SpringStreamCachingStrategyTest.java
+++ b/components/camel-spring-xml/src/test/java/org/apache/camel/spring/processor/SpringStreamCachingStrategyTest.java
@@ -17,6 +17,7 @@
package org.apache.camel.spring.processor;
import org.apache.camel.spring.SpringTestSupport;
+import org.apache.camel.util.IOHelper;
import org.junit.jupiter.api.Test;
import org.springframework.context.support.AbstractXmlApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
@@ -39,7 +40,7 @@ public class SpringStreamCachingStrategyTest extends SpringTestSupport {
assertTrue(context.getStreamCachingStrategy().isEnabled());
assertEquals(normalizePath("target/cachedir"),
normalizePath(context.getStreamCachingStrategy().getSpoolDirectory().toString()));
- assertEquals(Integer.valueOf(4096).intValue(), context.getStreamCachingStrategy().getBufferSize());
+ assertEquals(Integer.valueOf(IOHelper.DEFAULT_BUFFER_SIZE).intValue(), context.getStreamCachingStrategy().getBufferSize());
assertEquals(Long.valueOf(8192).longValue(), context.getStreamCachingStrategy().getSpoolThreshold());
assertEquals("java.io.ByteArrayInputStream",
context.getStreamCachingStrategy().getAllowClasses().iterator().next().getName());
diff --git a/core/camel-core-xml/src/generated/resources/META-INF/org/apache/camel/core/xml/streamCaching.json b/core/camel-core-xml/src/generated/resources/META-INF/org/apache/camel/core/xml/streamCaching.json
index 693094d5a35..a2b6e653ea1 100644
--- a/core/camel-core-xml/src/generated/resources/META-INF/org/apache/camel/core/xml/streamCaching.json
+++ b/core/camel-core-xml/src/generated/resources/META-INF/org/apache/camel/core/xml/streamCaching.json
@@ -23,7 +23,7 @@
"spoolUsedHeapMemoryThreshold": { "index": 8, "kind": "attribute", "displayName": "Spool Used Heap Memory Threshold", "group": "common", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Sets a percentage (1-99) of used heap memory threshold to activate spooling to disk." },
"spoolUsedHeapMemoryLimit": { "index": 9, "kind": "attribute", "displayName": "Spool Used Heap Memory Limit", "group": "common", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Sets what the upper bounds should be when spoolUsedHeapMemoryThreshold is in use." },
"spoolRules": { "index": 10, "kind": "attribute", "displayName": "Spool Rules", "group": "common", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Reference to one or more custom org.apache.camel.spi.StreamCachingStrategy.SpoolRule to use. Multiple rules can be separated by comma." },
- "bufferSize": { "index": 11, "kind": "attribute", "displayName": "Buffer Size", "group": "common", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "4096", "description": "Sets the buffer size to use when allocating in-memory buffers used for in-memory stream caches. The default size is org.apache.camel.util.IOHelper#DEFAULT_BUFFER_SIZE" },
+ "bufferSize": { "index": 11, "kind": "attribute", "displayName": "Buffer Size", "group": "common", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "16384", "description": "Sets the buffer size to use when allocating in-memory buffers used for in-memory stream caches. The default size is org.apache.camel.util.IOHelper#DEFAULT_BUFFER_SIZE" },
"removeSpoolDirectoryWhenStopping": { "index": 12, "kind": "attribute", "displayName": "Remove Spool Directory When Stopping", "group": "common", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether to remove the temporary directory when stopping. This option is default true" },
"statisticsEnabled": { "index": 13, "kind": "attribute", "displayName": "Statistics Enabled", "group": "common", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Sets whether statistics is enabled." },
"anySpoolRules": { "index": 14, "kind": "attribute", "displayName": "Any Spool Rules", "group": "common", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "false", "description": "Sets whether if just any of the org.apache.camel.spi.StreamCachingStrategy.SpoolRule rules returns true then shouldSpoolCache(long) returns true. If this option is false, then all the org.apache.camel.spi.StreamCac [...]
diff --git a/core/camel-util/src/main/java/org/apache/camel/util/IOHelper.java b/core/camel-util/src/main/java/org/apache/camel/util/IOHelper.java
index 610d5efcc7a..efe4d18c6d1 100644
--- a/core/camel-util/src/main/java/org/apache/camel/util/IOHelper.java
+++ b/core/camel-util/src/main/java/org/apache/camel/util/IOHelper.java
@@ -58,7 +58,8 @@ public final class IOHelper {
public static Supplier<Charset> defaultCharset = Charset::defaultCharset;
- public static final int DEFAULT_BUFFER_SIZE = 1024 * 4;
+ // Use the same default buffer size as the JVM
+ public static final int DEFAULT_BUFFER_SIZE = 16384;
public static final long INITIAL_OFFSET = 0;