This is an automated email from the ASF dual-hosted git repository.

jamesnetherton pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git


The following commit(s) were added to refs/heads/main by this push:
     new 918291f422 Fixes #9055. Drop the multipart null check that could never 
fail
918291f422 is described below

commit 918291f42253870983fba372aa109a6389585fe2
Author: Andrea Cosentino <[email protected]>
AuthorDate: Tue Sep 1 12:11:58 2026 +0200

    Fixes #9055. Drop the multipart null check that could never fail
    
    ServletProcessor.newServlet guarded the multipart wiring with
    `if (multipartConfig != null)`, which reads like the conditional treatment 
the
    options above it get. It is not: ServletConfig is a @ConfigMapping 
interface and
    multipart() is a non-Optional nested group, so SmallRye always materialises 
it
    with its defaults and the check can never fail.
    
    Applying the config only where it was configured is not an option: multipart
    handling is deliberately enabled on every Camel servlet, and
    CamelServletTest.multipartDefaultConfig posts a multipart request to the 
default
    servlet, which configures no multipart options at all.
    
    Remove the dead branch and record why the wiring is unconditional. 
Behaviour is
    unchanged.
    
    Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
---
 .../component/servlet/deployment/ServletProcessor.java   | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git 
a/extensions/servlet/deployment/src/main/java/org/apache/camel/quarkus/component/servlet/deployment/ServletProcessor.java
 
b/extensions/servlet/deployment/src/main/java/org/apache/camel/quarkus/component/servlet/deployment/ServletProcessor.java
index 18446102e4..60b8e740ad 100644
--- 
a/extensions/servlet/deployment/src/main/java/org/apache/camel/quarkus/component/servlet/deployment/ServletProcessor.java
+++ 
b/extensions/servlet/deployment/src/main/java/org/apache/camel/quarkus/component/servlet/deployment/ServletProcessor.java
@@ -109,14 +109,16 @@ class ServletProcessor {
             builder.addInitParam("executorRef", executorRef);
         });
 
+        // Unlike the options above, multipart handling is applied to every 
Camel servlet rather than only where it
+        // was configured, so that a route can consume a multipart request 
without the deployer opting in. The nested
+        // config group is never null under @ConfigMapping - it is always 
materialised with its defaults - so the
+        // null check this used to carry could never fail.
         MultipartConfig multipartConfig = servletConfig.multipart();
-        if (multipartConfig != null) {
-            builder.setMultipartConfig(new MultipartConfigElement(
-                    multipartConfig.location().orElse(null),
-                    multipartConfig.maxFileSize(),
-                    multipartConfig.maxRequestSize(),
-                    multipartConfig.fileSizeThreshold()));
-        }
+        builder.setMultipartConfig(new MultipartConfigElement(
+                multipartConfig.location().orElse(null),
+                multipartConfig.maxFileSize(),
+                multipartConfig.maxRequestSize(),
+                multipartConfig.fileSizeThreshold()));
 
         return builder.build();
     }

Reply via email to