gnodet opened a new pull request, #31178:
URL: https://github.com/apache/camel/pull/31178
## Summary
Two bugs in the `camel-dataset` component:
1. `DataSetEndpoint.waitForCompleteLatch()` with `minRate > 0` looped forever
2. `DataSetTestComponent` rejected Duration strings like `"2s"` for the
`timeout` URI parameter
## Root Cause
**Bug 1 — minRate infinite loop (`DataSetEndpoint`)**
The `waitForCompleteLatch()` override reused a single variable `count` as
both
the previous-iteration absolute counter and the computed delta:
```java
int count = getReceivedCounter(); // initial snapshot
do {
super.waitForCompleteLatch(1000L);
count = getReceivedCounter() - count; // BUG: overwrites snapshot with
delta
} while (count >= minRate);
```
After the first iteration `count` held the delta, not the previous total. On
the
next iteration `getReceivedCounter() - <delta>` produced an arbitrary value
(the full counter minus a small delta) which kept satisfying `>= minRate`.
Once all messages had arrived and the latch was open,
`waitForCompleteLatch(1000L)`
returned immediately, causing a tight infinite spin.
**Bug 2 — Duration string rejected for `timeout` (`DataSetTestComponent`)**
`createEndpoint()` manually extracted the `timeout` parameter as `Long.class`
via `getAndRemoveParameter()`, then removed it from the map before
`setProperties()` ran. Because the raw string `"2s"` cannot be cast to
`Long`,
any Duration-formatted value threw a `NumberFormatException`. The parameter
is
declared `javaType = "java.time.Duration"` in `DataSetTestEndpoint` — Camel's
type converter (invoked by `setProperties()`) handles both plain
milliseconds and
time-pattern strings.
## Fix
**Bug 1:** Use separate `prev`/`curr`/`delta` variables so the absolute
snapshot
is preserved across iterations.
**Bug 2:** Remove the manual extraction entirely and let `setProperties()`
resolve
the value through the standard type converter.
## Tests
- `DataSetMinRateTest` — 200-message dataset with `produceDelay=10ms` and
`resultWaitTime=100ms` forces the initial latch to expire early,
exercising the
minRate loop. `@Timeout(30)` causes the test to fail fast (instead of
hanging
the fork) if the infinite-spin bug is reintroduced. `minRate=1` reliably
reproduces the original spin while giving CI margin on loaded machines.
- `DataSetTestTimeoutDurationTest` — verifies that `timeout=2s` and
`timeout=1500`
are both accepted at endpoint creation time, and that a route using a
Duration
timeout string starts and completes normally.
Fixes 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]