This is an automated email from the ASF dual-hosted git repository.
nfilotto pushed a commit to branch camel-4.0.x
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/camel-4.0.x by this push:
new 286499b1f88 CAMEL-20152: camel-jetty - Fix a file size threshold
(#12256)
286499b1f88 is described below
commit 286499b1f88c17a206ba9849fe6c318b64bfe584
Author: Nicolas Filotto <[email protected]>
AuthorDate: Wed Nov 29 15:22:20 2023 +0100
CAMEL-20152: camel-jetty - Fix a file size threshold (#12256)
## 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 ba3b3f177eb..cf3080b96c9 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;
@@ -1150,7 +1154,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());