gnodet opened a new pull request, #30851:
URL: https://github.com/apache/camel/pull/30851
## Summary
Fix a race condition that caused
`CommunicationLossTest.lostSessionReportsTheNodeAndResendsItsValue()` to fail
intermittently.
## Root Cause
After the first connection drop and recovery, the OPC UA subscription
**republish** mechanism can deliver stale `"Foo"` notifications after
`item1Endpoint.reset()`. The original assertion:
```java
item1Endpoint.reset();
item1Endpoint.expectedMessageCount(1);
testBody(item1Endpoint.message(0), assertGoodValue("Bar"));
producer1.sendBody("Bar");
item1Endpoint.assertIsSatisfied();
```
Would fail when a stale republish `"Foo"` message arrived as `message(0)`
before the new `"Bar"` write was delivered by the subscription. The OPC UA
server queues Publish responses for the dropped channel and can send them to
the reactivated session before the client's `republishNotification` delivers
the actual missed notification.
This race is distinct from the one addressed by PR #30817 (CAMEL-27503),
which fixes a different generation-guard issue.
## Fix
Replace the fixed `message(0)` assertion with Awaitility, waiting until at
least one received exchange carries a good `"Bar"` value. This tolerates any
number of stale republish deliveries that may arrive after the reset:
```java
item1Endpoint.reset();
producer1.sendBody("Bar");
await().atMost(10, TimeUnit.SECONDS).untilAsserted(() -> assertTrue(
item1Endpoint.getReceivedExchanges().stream()
.anyMatch(e -> {
DataValue v = e.getMessage().getBody(DataValue.class);
return v != null && v.getStatusCode().isGood()
&& "Bar".equals(v.getValue().getValue());
}),
"Expected a 'Bar' value notification after reset, but none
arrived"));
```
## Tests
The existing `lostSessionReportsTheNodeAndResendsItsValue()` test covers
this scenario — it was the flaky test. The fix makes the assertion robust
against late OPC UA republish notifications without changing the test's intent.
Fixes CAMEL-27559
---
_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]