gnodet-bot commented on code in PR #31172:
URL: https://github.com/apache/camel/pull/31172#discussion_r4756724630
##########
components/camel-seda/src/main/java/org/apache/camel/component/seda/SedaEndpoint.java:
##########
@@ -487,6 +493,15 @@ public boolean isDiscardWhenFull() {
public void setConcurrentConsumers(int concurrentConsumers) {
this.concurrentConsumers = concurrentConsumers;
+ this.concurrentConsumersSet = true;
+ }
+
+ /**
+ * Package-private: applies the component-level default without marking
the value as user-set. Called by
+ * {@link SedaComponent} to propagate its default; {@link
#setConcurrentConsumers(int)} is for user-facing calls.
+ */
+ void setConcurrentConsumersDefault(int concurrentConsumers) {
+ this.concurrentConsumers = concurrentConsumers;
Review Comment:
💬 **Note — coupling with caller:** The `setConcurrentConsumersDefault` body
sets `this.concurrentConsumers` directly without touching
`concurrentConsumersSet`, which is correct for a default-propagation path.
Worth noting: if any future subclass or test instantiates a `SedaEndpoint` and
calls this method without subsequently going through
`SedaComponent.createEndpoint`, the flag stays `false` and the `doInit` reset
can fire unexpectedly. A one-line clarification in the existing Javadoc (e.g.
*"Callers must ensure that any user-provided override is applied afterwards via
`setConcurrentConsumers(int)`"*) would prevent future misuse.
##########
core/camel-core/src/test/java/org/apache/camel/component/seda/SedaSizeSentinelTest.java:
##########
@@ -0,0 +1,152 @@
+/*
+ * 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.seda;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+/**
+ * Regression tests for CAMEL-27896:
+ * <ul>
+ * <li>size=1000 (the SEDA default) or size=Integer.MAX_VALUE on an endpoint
created after context start must not be
+ * treated as "not set" and must not be overridden by the component
default.</li>
+ * <li>concurrentConsumers=1 with virtualThreadPerTask=true must be preserved
and must not be reset to 0.</li>
+ * </ul>
+ */
+class SedaSizeSentinelTest extends ContextTestSupport {
Review Comment:
🔧 **Nit — test class name scope:** `SedaSizeSentinelTest` now covers both
size and `concurrentConsumers` sentinel scenarios (four of six test methods).
Consider `SedaSentinelFlagTest` or `SedaDefaultSentinelTest` to reflect the
broader scope. Not blocking.
##########
core/camel-core/src/test/java/org/apache/camel/component/seda/SedaSizeSentinelTest.java:
##########
@@ -0,0 +1,152 @@
+/*
+ * 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.seda;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+/**
+ * Regression tests for CAMEL-27896:
+ * <ul>
+ * <li>size=1000 (the SEDA default) or size=Integer.MAX_VALUE on an endpoint
created after context start must not be
+ * treated as "not set" and must not be overridden by the component
default.</li>
+ * <li>concurrentConsumers=1 with virtualThreadPerTask=true must be preserved
and must not be reset to 0.</li>
+ * </ul>
+ */
+class SedaSizeSentinelTest extends ContextTestSupport {
+
+ /**
+ * When a user explicitly sets size=1000 (which equals
SedaConstants.QUEUE_SIZE) on an endpoint that is created
+ * after context start, the size must not be silently treated as "not set"
and must not be replaced by the component
+ * default.
+ */
+ @Test
+ void testExplicitSizeOfDefaultValueIsRespected() throws Exception {
+ // The component has a custom queueSize different from the endpoint's
explicit size=1000.
+ SedaComponent comp = context.getComponent("seda", SedaComponent.class);
+ int originalComponentQueueSize = comp.getQueueSize();
+ comp.setQueueSize(42);
+ try {
+ // Create endpoint after context start with size explicitly set to
1000.
+ SedaEndpoint ep =
context.getEndpoint("seda:sentinelQueue1000?size=1000", SedaEndpoint.class);
+ ep.getQueue(); // force queue creation
+ assertEquals(1000, ep.getSize(),
Review Comment:
🔧 **Nit — assertion strength:** `assertEquals(1000, ep.getSize(), ...)`
asserts the endpoint's internal field, not the actual queue capacity. Asserting
`ep.getQueue().remainingCapacity()` (or `ep.getQueue().size() +
ep.getQueue().remainingCapacity()`) would give stronger proof that the queue
was physically created with the requested capacity, not just that the field was
set. Same applies to `testExplicitSizeMaxValueIsRespected` (line 70).
##########
core/camel-core/src/test/java/org/apache/camel/component/seda/SedaSizeSentinelTest.java:
##########
@@ -0,0 +1,152 @@
+/*
+ * 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.seda;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+/**
+ * Regression tests for CAMEL-27896:
+ * <ul>
+ * <li>size=1000 (the SEDA default) or size=Integer.MAX_VALUE on an endpoint
created after context start must not be
+ * treated as "not set" and must not be overridden by the component
default.</li>
+ * <li>concurrentConsumers=1 with virtualThreadPerTask=true must be preserved
and must not be reset to 0.</li>
+ * </ul>
+ */
+class SedaSizeSentinelTest extends ContextTestSupport {
+
+ /**
+ * When a user explicitly sets size=1000 (which equals
SedaConstants.QUEUE_SIZE) on an endpoint that is created
+ * after context start, the size must not be silently treated as "not set"
and must not be replaced by the component
+ * default.
+ */
+ @Test
+ void testExplicitSizeOfDefaultValueIsRespected() throws Exception {
+ // The component has a custom queueSize different from the endpoint's
explicit size=1000.
+ SedaComponent comp = context.getComponent("seda", SedaComponent.class);
+ int originalComponentQueueSize = comp.getQueueSize();
+ comp.setQueueSize(42);
+ try {
+ // Create endpoint after context start with size explicitly set to
1000.
+ SedaEndpoint ep =
context.getEndpoint("seda:sentinelQueue1000?size=1000", SedaEndpoint.class);
+ ep.getQueue(); // force queue creation
+ assertEquals(1000, ep.getSize(),
+ "Explicitly set size=1000 must be respected even though it
matches SedaConstants.QUEUE_SIZE");
+ } finally {
+ comp.setQueueSize(originalComponentQueueSize);
+ }
+ }
+
+ /**
+ * When a user explicitly sets size=Integer.MAX_VALUE on an endpoint
(unbounded queue), the size must not be
+ * silently treated as "not set" and replaced by the component default.
+ */
+ @Test
+ void testExplicitSizeMaxValueIsRespected() throws Exception {
+ SedaComponent comp = context.getComponent("seda", SedaComponent.class);
+ int originalComponentQueueSize = comp.getQueueSize();
+ comp.setQueueSize(42);
+ try {
+ SedaEndpoint ep =
context.getEndpoint("seda:sentinelQueueMax?size=" + Integer.MAX_VALUE,
SedaEndpoint.class);
+ ep.getQueue();
+ assertEquals(Integer.MAX_VALUE, ep.getSize(),
+ "Explicitly set size=Integer.MAX_VALUE must be respected
and must not be replaced by the component default");
+ } finally {
+ comp.setQueueSize(originalComponentQueueSize);
+ }
+ }
+
+ /**
+ * When a user explicitly sets concurrentConsumers=1 together with
virtualThreadPerTask=true, the value must be
+ * preserved and must not be reset to 0 by doInit().
+ */
+ @Test
+ void testConcurrentConsumersOneWithVirtualThreadsIsRespected() throws
Exception {
+ // The route uses concurrentConsumers=1 explicitly with
virtualThreadPerTask=true.
+ // If the bug is present, doInit() would reset it to 0.
+ SedaEndpoint ep = context.getEndpoint(
+
"seda:vtQueueExplicit1?virtualThreadPerTask=true&concurrentConsumers=1",
+ SedaEndpoint.class);
+ // The endpoint is already initialised by context.getEndpoint();
getConcurrentConsumers() reflects doInit().
+ assertEquals(1, ep.getConcurrentConsumers(),
+ "Explicitly set concurrentConsumers=1 must not be overridden
to 0 when virtualThreadPerTask=true");
+ }
+
+ /**
+ * When virtualThreadPerTask=true and concurrentConsumers is not set, the
default must be changed to 0 (unlimited),
+ * because the fixed default of 1 defeats the purpose of thread-per-task
mode.
+ */
+ @Test
+ void testConcurrentConsumersDefaultsToZeroWithVirtualThreads() throws
Exception {
+ SedaEndpoint ep = context.getEndpoint(
+ "seda:vtQueueDefault1?virtualThreadPerTask=true",
+ SedaEndpoint.class);
+ assertEquals(0, ep.getConcurrentConsumers(),
+ "When virtualThreadPerTask=true and concurrentConsumers is not
set explicitly, it should default to 0");
+ }
+
+ /**
+ * When the SEDA component has a custom concurrentConsumers default (e.g.
3) and an endpoint uses
+ * virtualThreadPerTask=true without an explicit concurrentConsumers, the
component value must be preserved.
+ */
+ @Test
+ void testComponentConcurrentConsumersPreservedWithVirtualThreads() throws
Exception {
+ SedaComponent comp = context.getComponent("seda", SedaComponent.class);
+ int originalConcurrentConsumers = comp.getConcurrentConsumers();
+ comp.setConcurrentConsumers(3);
+ try {
+ SedaEndpoint ep = context.getEndpoint(
+ "seda:vtQueueCompDefault?virtualThreadPerTask=true",
+ SedaEndpoint.class);
+ assertEquals(3, ep.getConcurrentConsumers(),
+ "Component-level concurrentConsumers=3 must not be reset
to 0 when virtualThreadPerTask=true");
+ } finally {
+ comp.setConcurrentConsumers(originalConcurrentConsumers);
+ }
+ }
+
+ /**
+ * Full route smoke test: an endpoint with virtualThreadPerTask=true and
concurrentConsumers=1 must actually process
+ * messages correctly.
+ */
+ @Test
+ void testVirtualThreadsWithConcurrentConsumersOneProcessesMessages()
throws Exception {
Review Comment:
🔧 **Nit — smoke test concurrency assertion:** The test sends 3 messages and
asserts they arrive, but does not verify that `concurrentConsumers=1` actually
limits processing to one message at a time. A stronger test could use a
`CountDownLatch` inside the route processor to detect overlapping execution.
That said, the setter-correctness path is already covered by the unit assertion
in `testConcurrentConsumersOneWithVirtualThreadsIsRespected`, so this is a
minor gap.
--
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]