Copilot commented on code in PR #200:
URL:
https://github.com/apache/maven-toolchains-plugin/pull/200#discussion_r4302563818
##########
src/main/java/org/apache/maven/plugins/toolchain/jdk/ToolchainDiscoverer.java:
##########
@@ -314,11 +314,15 @@ ToolchainModel doGetToolchainModel(Path jdk) {
return model;
}
- private static Path getCanonicalPath(Path path) {
+ static Path getCanonicalPath(Path path) {
try {
return path.toRealPath();
} catch (IOException e) {
- return
getCanonicalPath(path.getParent()).resolve(path.getFileName());
+ Path parent = path.getParent();
+ if (parent == null) {
+ return path.toAbsolutePath().normalize();
Review Comment:
The new root-path test normally returns from `toRealPath()`, so it still
passes if this null-parent guard is removed. Add a deterministic test using a
`Path` test double or provider whose `toRealPath()` throws `IOException` and
whose `getParent()` returns null. Assert that the result equals the normalized
absolute root path, so the test verifies the fallback and fails without the
guard.
--
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]