gnodet commented on code in PR #1558:
URL: https://github.com/apache/maven-mvnd/pull/1558#discussion_r4792972725
##########
integration-tests/src/test/java/org/mvndaemon/mvnd/junit/TestRegistry.java:
##########
@@ -84,6 +84,12 @@ public void awaitIdle(String daemonId) {
Assertions.assertThat(deadline)
.withFailMessage("Daemon %s should have become idle within
%d", daemonId, timeoutMs)
.isGreaterThan(System.currentTimeMillis());
+ try {
Review Comment:
_Claude Code on behalf of Guillaume Nodet_
**Excellent addition** - this sleep prevents the tight busy-loop that was
causing file lock contention on each `getAll()` call.
The interrupt handling is correct (`Thread.currentThread().interrupt()`
preserves the interrupt status before throwing).
**Minor optimization suggestion**: The current structure sleeps even when
the daemon becomes idle, adding an unnecessary 100ms delay. Consider
restructuring to avoid this:
```java
while (System.currentTimeMillis() < deadline) {
DaemonInfo info = getAll().stream()
.filter(di -> di.getId().equals(daemonId))
.findFirst()
.orElseThrow(() -> new IllegalStateException(
"Daemon " + daemonId + " is not available in the registry"));
if (info.getState() == DaemonState.Idle) {
return; // Exit immediately without sleeping
}
try {
Thread.sleep(100);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new RuntimeException(e);
}
}
// Timeout - fail here
Assertions.fail(...);
```
This is a minor performance improvement - the current implementation is
functionally correct.
--
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]