You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by nf...@apache.org on 2023/11/29 14:25:01 UTC
(camel) branch camel-3.20.x updated: CAMEL-20152: camel-jetty - Fix a file size threshold (#12255)
This is an automated email from the ASF dual-hosted git repository.
nfilotto pushed a commit to branch camel-3.20.x
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/camel-3.20.x by this push:
new 9127e86ce97 CAMEL-20152: camel-jetty - Fix a file size threshold (#12255)
9127e86ce97 is described below
commit 9127e86ce97dc6255b69dbd78f28c19fbb1d74b8
Author: Nicolas Filotto <es...@users.noreply.github.com>
AuthorDate: Wed Nov 29 15:24:55 2023 +0100
CAMEL-20152: camel-jetty - Fix a file size threshold (#12255)
## Motivation
In the case of multipart, the content is kept in memory which can lead to an OOME, it is due to the fact that the `fileSizeThreshold` is set to `0` by default which should mean that the content is stored on disk according to the Jakarta Javadoc but it is not what the Jetty code expects.
## Modifications:
* Set the default file size threshold to 10 MB by default
---
.../java/org/apache/camel/component/jetty/JettyHttpComponent.java | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
index c69a50c96ae..4cac633ca1d 100644
--- a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
+++ b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
@@ -106,6 +106,10 @@ public abstract class JettyHttpComponent extends HttpCommonComponent
private static final String JETTY_SSL_KEYSTORE = "org.eclipse.jetty.ssl.keystore";
private static final String JETTY_SSL_KEYPASSWORD = "org.eclipse.jetty.ssl.keypassword";
private static final String JETTY_SSL_PASSWORD = "org.eclipse.jetty.ssl.password";
+ /**
+ * The default value in bytes of the threshold beyond which the multipart files are written to disk to prevent OOME.
+ */
+ private static final int DEFAULT_FILE_SIZE_THRESHOLD = 10 * 1024 * 1024;
protected String sslKeyPassword;
protected String sslPassword;
@@ -1172,7 +1176,8 @@ public abstract class JettyHttpComponent extends HttpCommonComponent
//must register the MultipartConfig to make jetty server multipart aware
holder.getRegistration()
- .setMultipartConfig(new MultipartConfigElement(file.getParentFile().getAbsolutePath(), -1, -1, 0));
+ .setMultipartConfig(new MultipartConfigElement(
+ file.getParentFile().getAbsolutePath(), -1, -1, DEFAULT_FILE_SIZE_THRESHOLD));
// use rest enabled resolver in case we use rest
camelServlet.setServletResolveConsumerStrategy(new HttpRestServletResolveConsumerStrategy());