gnodet commented on PR #1165:
URL:
https://github.com/apache/maven-compiler-plugin/pull/1165#issuecomment-7394871692
_Claude Code on behalf of Guillaume Nodet_
**Nit: Cascade loop error message could be clearer**: The safety bound for
the cascade loop is `originalSourceFiles.size() + 1`. If a bug causes the same
file to appear in `toCompile` multiple times, the loop iterates N+1 times then
throws `IllegalStateException` with message "possible dependency cycle".
However, the real cause might be a state tracking bug rather than a cycle,
making the error message misleading.
**Fix**: Track which files were compiled in each round and detect duplicates
explicitly:
```java
var compiledPerRound = new HashSet<Path>();
for (int round = 0; round < maxRounds; round++) {
Set<Path> toCompile = round == 0 ? initialCompile :
processCompiledClasses();
if (toCompile.isEmpty()) {
break;
}
for (Path f : toCompile) {
if (!compiledPerRound.add(f)) {
throw new IllegalStateException(
"File appeared in toCompile twice: " + f +
" (round " + round + "). This indicates a bug in dependency
tracking."
);
}
}
// ... compile
}
```
--
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]