gnodet opened a new pull request, #31158:
URL: https://github.com/apache/camel/pull/31158

   ## Summary
   
   Fixes two bugs in `camel-dataset`:
   
   1. `DataSetEndpoint.waitForCompleteLatch()` with `minRate > 0` entered an 
infinite busy-spin
      once all expected messages had been delivered.
   2. `DataSetTestComponent.createEndpoint()` rejected duration strings like 
`"2s"` for the
      `timeout` parameter, throwing a `NumberFormatException`, even though the 
catalog declares
      `timeout` with `javaType = "java.time.Duration"`.
   
   ## Root Cause
   
   **Bug 1 — minRate infinite loop:**
   The loop variable `count` was overwritten with the per-second delta (`count 
= getReceivedCounter() - count`)
   on every iteration. On the first iteration after all messages arrived, 
`count` became 0
   (correct: no new messages). On the second iteration, `count` held 0 (the 
previous delta),
   so `getReceivedCounter() - count` equalled the total received count — a 
large positive number —
   causing `count >= minRate` to be true again. The loop never exited.
   
   **Bug 2 — Duration string rejection:**
   `getAndRemoveParameter(parameters, "timeout", Long.class)` tried to coerce 
the raw URI parameter
   value directly to `Long`, which fails for strings like `"2s"`. The generated
   `DataSetTestEndpointConfigurer` already handles this correctly via
   `property(camelContext, Duration.class, value).toMillis()`, but the manual 
extraction ran first
   and bypassed the configurer.
   
   ## Fix
   
   **Bug 1:** Use separate `prev` and `curr` variables. Each iteration computes 
the delta as
   `curr - prev` and updates `prev = curr`, keeping a correct running snapshot.
   
   **Bug 2:** Remove the manual `getAndRemoveParameter` extraction. 
`setProperties(answer, parameters)`
   already invokes the generated configurer, which handles both plain 
millisecond values and
   duration strings (`"2s"`, `"PT2S"`, etc.).
   
   ## Tests
   
   - `DataSetMinRateTest`: verifies that `assertMockEndpointsSatisfied()` 
completes within 10 seconds
     when `minRate=1` and all 5 dataset messages have been received. Before the 
fix, this test would
     hang indefinitely.
   - `DataSetTestTimeoutDurationTest`: verifies that `timeout=2s` resolves to 
2000 ms, that plain
     millisecond values (`timeout=1500`) still work, and that an end-to-end 
route with `timeout=1s`
     starts and completes without error.
   
   The existing `DataSetTest` (which uses `minRate=50`) also passes, confirming 
no regression.
   
   Fixes https://issues.apache.org/jira/browse/CAMEL-27868
   
   ---
   _Hermes Agent (Claude Sonnet 4.6) on behalf of Guillaume Nodet_
   


-- 
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