This is an automated email from the ASF dual-hosted git repository. nfilotto pushed a commit to branch camel-3.21.x in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/camel-3.21.x by this push: new 6047d9ff3be CAMEL-20152: camel-jetty - Fix a file size threshold (#12252) 6047d9ff3be is described below commit 6047d9ff3be10e675e18cabdb6ec9f563c85f93d Author: Nicolas Filotto <essob...@users.noreply.github.com> AuthorDate: Wed Nov 29 15:22:00 2023 +0100 CAMEL-20152: camel-jetty - Fix a file size threshold (#12252) ## 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());