Skip to content

[maven-4.0.x] DefaultSettingsBuilder: dead Windows drive-relative path handling #12604

Description

@elharo

DefaultSettingsBuilder: Dead Windows drive-relative path handling

Found in: maven-4.0.x branch
File: impl/maven-impl/src/main/java/org/apache/maven/impl/settings/DefaultSettingsBuilder.java (lines 131-137)
Severity: Medium

Description

The check for drive-relative Windows paths is always false on all platforms:

if (localRepository != null && !localRepository.isEmpty()) {
    Path file = Paths.get(localRepository);
    if (!file.isAbsolute() && file.toString().startsWith(File.separator)) {
        effective = effective.withLocalRepository(file.toAbsolutePath().toString());
    }
}

On Windows, a path starting with \ (e.g., \foo\bar) is already absolute (relative to the current drive root), so file.isAbsolute() returns true and the inner condition fails. On Unix (/ separator), any path starting with / is also absolute. This means the condition !file.isAbsolute() && file.toString().startsWith(File.separator) is always false, making the entire block dead code. The intended fix for drive-relative paths is never executed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions