gnodet-bot commented on code in PR #26553:
URL: https://github.com/apache/camel/pull/26553#discussion_r4038250802


##########
core/camel-core/src/test/java/org/apache/camel/processor/PooledExchangeSplitLeakTest.java:
##########
@@ -0,0 +1,74 @@
+/*
+ * 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.processor;
+
+import java.util.List;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.ExtendedCamelContext;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.impl.engine.PooledExchangeFactory;
+import org.apache.camel.impl.engine.PooledProcessorExchangeFactory;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertNull;
+
+public class PooledExchangeSplitLeakTest extends ContextTestSupport {
+
+    @Override
+    protected CamelContext createCamelContext() throws Exception {
+        CamelContext camelContext = super.createCamelContext();
+        ExtendedCamelContext ecc = camelContext.getCamelContextExtension();
+        ecc.setExchangeFactory(new PooledExchangeFactory());
+        ecc.setProcessorExchangeFactory(new PooledProcessorExchangeFactory());
+        return camelContext;
+    }
+
+    @Test
+    public void testSplitChildrenDoNotLeakStateBetweenMessages() throws 
Exception {
+        MockEndpoint mock = getMockEndpoint("mock:split");
+        mock.expectedMessageCount(2);
+
+        template.sendBody("direct:start", List.of("first"));
+        template.sendBody("direct:start", List.of("second"));
+
+        mock.assertIsSatisfied();
+
+        // the child of the second message is a reused pooled exchange; it 
must not carry the first child's state
+        assertNull(mock.getExchanges().get(1).getProperty("leakProp"));
+        assertNull(mock.getExchanges().get(1).getVariable("leak"));
+    }
+
+    @Override

Review Comment:
   ⚠️ **Missing positive assertion — test can pass vacuously without the fix.**
   
   The test only asserts that the *second* message's child doesn't have the 
leaked state, but never verifies that the *first* message's child actually 
*set* `leakProp` / `leak`. If the processor's `if ("first".equals(...))` branch 
silently never fired (wrong body type, wrong split strategy, routing 
short-circuit), the test would pass on `main` without the fix — and wouldn't 
actually reproduce the regression.
   
   Add a positive guard assertion:
   
   ```suggestion
           // verify the first child DID carry the state (guards against 
vacuous pass)
           assertEquals("from-first", 
mock.getExchanges().get(0).getProperty("leakProp"));
           // the child of the second message is a reused pooled exchange; it 
must not carry the first child's state
           assertNull(mock.getExchanges().get(1).getProperty("leakProp"));
           assertNull(mock.getExchanges().get(1).getVariable("leak"));
   ```
   
   Also add `assertEquals` to the static import.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to