This is an automated email from the ASF dual-hosted git repository. gnodet pushed a commit to branch fix/camel-27962-smooks-lazy-start-producer in repository https://gitbox.apache.org/repos/asf/camel.git
commit 51552b989fc8f862928f7e2a1cf0605c357890e4 Author: Guillaume Nodet <[email protected]> AuthorDate: Fri Dec 4 12:06:49 2026 +0100 CAMEL-27962: camel-smooks lazyStartProducer now properly binds to endpoint The lazyStartProducer option was incorrectly being bound to SmooksProcessor instead of SmooksEndpoint. This fix: - Removes the public lazyStartProducer field from SmooksProcessor - Adds a package-private lazyStart field that is set by the endpoint - The endpoint now properly exposes lazyStartProducer (inherited from DefaultEndpoint) - Added test to verify the fix Co-Authored-By: Claude Sonnet 4.5 <[email protected]> --- .../camel/component/smooks/SmooksEndpoint.java | 1 + .../camel/component/smooks/SmooksProcessor.java | 12 ++--- .../smooks/SmooksLazyStartProducerTest.java | 55 ++++++++++++++++++++++ 3 files changed, 60 insertions(+), 8 deletions(-) diff --git a/components/camel-smooks/src/main/java/org/apache/camel/component/smooks/SmooksEndpoint.java b/components/camel-smooks/src/main/java/org/apache/camel/component/smooks/SmooksEndpoint.java index 3d481b2efcd7..5d7b2b689b00 100644 --- a/components/camel-smooks/src/main/java/org/apache/camel/component/smooks/SmooksEndpoint.java +++ b/components/camel-smooks/src/main/java/org/apache/camel/component/smooks/SmooksEndpoint.java @@ -90,6 +90,7 @@ public class SmooksEndpoint extends DefaultEndpoint { @Override protected void doStart() throws Exception { super.doStart(); + smooksProcessor.setLazyStart(isLazyStartProducer()); ServiceHelper.startService(smooksProcessor); } diff --git a/components/camel-smooks/src/main/java/org/apache/camel/component/smooks/SmooksProcessor.java b/components/camel-smooks/src/main/java/org/apache/camel/component/smooks/SmooksProcessor.java index bacee9499e6b..d00b9a6e9dc3 100644 --- a/components/camel-smooks/src/main/java/org/apache/camel/component/smooks/SmooksProcessor.java +++ b/components/camel-smooks/src/main/java/org/apache/camel/component/smooks/SmooksProcessor.java @@ -89,9 +89,9 @@ public class SmooksProcessor extends ServiceSupport implements Processor, CamelC private String configUri; private String reportPath; private Boolean allowExecutionContextFromHeader = false; - private Boolean lazyStartProducer = false; private boolean allowExternalEntities; private boolean hardenXmlInput; + private boolean lazyStart; private final Set<VisitorAppender> visitorAppender = new HashSet<>(); private final Map<String, Visitor> selectorVisitorMap = new HashMap<>(); @@ -350,12 +350,8 @@ public class SmooksProcessor extends ServiceSupport implements Processor, CamelC smooks.addVisitor(entry.getValue(), entry.getKey()); } - public Boolean getLazyStartProducer() { - return lazyStartProducer; - } - - public void setLazyStartProducer(Boolean lazyStartProducer) { - this.lazyStartProducer = lazyStartProducer; + void setLazyStart(boolean lazyStart) { + this.lazyStart = lazyStart; } @Override @@ -376,7 +372,7 @@ public class SmooksProcessor extends ServiceSupport implements Processor, CamelC addAppender(smooks, visitorAppender); addVisitor(smooks, selectorVisitorMap); - if (!lazyStartProducer) { + if (!lazyStart) { smooks.createExecutionContext(); } diff --git a/components/camel-smooks/src/test/java/org/apache/camel/component/smooks/SmooksLazyStartProducerTest.java b/components/camel-smooks/src/test/java/org/apache/camel/component/smooks/SmooksLazyStartProducerTest.java new file mode 100644 index 000000000000..370dc12e1e1b --- /dev/null +++ b/components/camel-smooks/src/test/java/org/apache/camel/component/smooks/SmooksLazyStartProducerTest.java @@ -0,0 +1,55 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.smooks; + +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.test.junit6.CamelTestSupport; +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +class SmooksLazyStartProducerTest extends CamelTestSupport { + + @Test + void testLazyStartProducerTrue() throws Exception { + SmooksEndpoint endpoint = context.getEndpoint("smooks://edi-to-xml-smooks-config.xml?lazyStartProducer=true", + SmooksEndpoint.class); + assertThat(endpoint.isLazyStartProducer()).isTrue(); + } + + @Test + void testLazyStartProducerFalse() throws Exception { + SmooksEndpoint endpoint = context.getEndpoint("smooks://edi-to-xml-smooks-config.xml?lazyStartProducer=false", + SmooksEndpoint.class); + assertThat(endpoint.isLazyStartProducer()).isFalse(); + } + + @Test + void testLazyStartProducerDefault() throws Exception { + SmooksEndpoint endpoint = context.getEndpoint("smooks://edi-to-xml-smooks-config.xml", SmooksEndpoint.class); + assertThat(endpoint.isLazyStartProducer()).isFalse(); + } + + @Override + protected RouteBuilder createRouteBuilder() { + return new RouteBuilder() { + public void configure() { + // No routes needed for this test + } + }; + } +}
