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/10/21 11:30:11 UTC
[camel] branch main updated: CAMEL-19975: Convert file to ByteBuffer should fail if the file is too large
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 51e48ef8484 CAMEL-19975: Convert file to ByteBuffer should fail if the file is too large
51e48ef8484 is described below
commit 51e48ef8484c415985b3e9fcb2dc50bd5f37135b
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sat Oct 21 13:29:58 2023 +0200
CAMEL-19975: Convert file to ByteBuffer should fail if the file is too large
---
.../src/main/java/org/apache/camel/converter/NIOConverter.java | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/core/camel-base/src/main/java/org/apache/camel/converter/NIOConverter.java b/core/camel-base/src/main/java/org/apache/camel/converter/NIOConverter.java
index 8d3aed054dd..91080749d9d 100644
--- a/core/camel-base/src/main/java/org/apache/camel/converter/NIOConverter.java
+++ b/core/camel-base/src/main/java/org/apache/camel/converter/NIOConverter.java
@@ -71,6 +71,13 @@ public final class NIOConverter {
@Converter(order = 5)
public static ByteBuffer toByteBuffer(File file) throws IOException {
+ if (file.length() > Integer.MAX_VALUE) {
+ // very big file we cannot load into memory
+ throw new IOException(
+ "Cannot convert file: " + file.getName() + " to ByteBuffer. The file length is too large: "
+ + file.length());
+ }
+
InputStream in = null;
try {
byte[] buf = new byte[(int) file.length()];