Repository navigation
requireFilesExist should accept a symbolic link - #1031
Merged
slawekjaranowski merged 1 commit intoSep 29, 2026
Merged
Conversation
7 of 8 tasks
The case check added for apache#477 compares the configured file name with the one from getCanonicalFile(), which resolves a symbolic link to its target. A link whose name differs from its target name - the normal case - was therefore reported as missing. Keep getCanonicalFile() for a regular file, where nothing is resolved away, and look the name up among the entries of the parent directory when the path is a symbolic link. A directory entry carries the name as it is stored on disk. toRealPath(NOFOLLOW_LINKS) would be cheaper but is not an option: it corrects the case only since JDK 21, so on an older JDK the check would silently pass for any name. Move the check to AbstractRequireFiles behind a shared fileExists(File), so that all three rules share one notion of an existing file. This changes behaviour on a case-insensitive filesystem: requireFilesDontExist no longer fails on a file whose name differs only in case, and requireFilesSize reports such a file as missing instead of measuring a different file. Document the case handling on the three rule pages. The symbolic link tests and the relative path IT come from apache#297. The try/catch blocks in the touched test classes are converted to assertThrows along the way. Fixes apache#501 Co-authored-by: Jason Irwin <jason.irwin@idoxgroup.com> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
slawekjaranowski
force-pushed
the
require-files-exist-symlink
branch
from
September 17, 2026 05:33
c8f6c4e to
d8047a9
Compare
slachiewicz
approved these changes
Sep 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #501
requireFilesExistreports an existing symbolic link as missing. The case checkadded for #477 compares the configured file name with the one from
getCanonicalFile(), which resolves a link to its target, so a link whose namediffers from its target name β the normal case β never matches.
The
..and.part of #501 was already fixed in #1011; this covers theremaining symbolic link part.
How
toRealPath(NOFOLLOW_LINKS)replacesgetCanonicalFile(). It still corrects thecase on a case-insensitive filesystem and still collapses
..and., butleaves the link itself alone:
getCanonicalFile()toRealPath(NOFOLLOW_LINKS)POM.xmlvspom.xml..The check moves to
AbstractRequireFilesbehind a sharedfileExists(File), sorequireFilesExist,requireFilesDontExistandrequireFilesSizeshare onenotion of an existing file.
Behavioural change
On a case-insensitive filesystem (Windows, default macOS) a file whose name
differs only in case is now consistently treated as a different file:
requireFilesDontExistno longer fails on itrequireFilesSizereports it as missing instead of measuring a different fileOn a case-sensitive filesystem nothing changes. The three rule pages document
this.
Credit
The symbolic link tests and the relative path IT come from #297 by @roadSurfer.
That PR proposed reverting #477 entirely; this keeps the case check and fixes
the link handling instead, so #297 can be closed.
mvn verifyto make sure basic checks pass.mvn -Prun-its verify).