Skip to content

NPE in ManifestConfiguration.getClasspathPrefix() when prefix is set to null #367

Description

@elharo

Affected version: all

Description:

ManifestConfiguration.getClasspathPrefix() at line 248 calls .replaceAll() directly on the field without a null check:

public String getClasspathPrefix() {
    String cpp = classpathPrefix.replaceAll("\\\\", "/");
    if (cpp.length() != 0 && !cpp.endsWith("/")) {
        cpp += "/";
    }
    return cpp;
}

The field is initialized to "" at line 53, but the setter setClasspathPrefix(String) at line 220 stores the value as-is without a null guard:

public void setClasspathPrefix(String classpathPrefix) {
    this.classpathPrefix = classpathPrefix;
}

If any caller passes null to the setter, the getter throws NPE on null.replaceAll().

Impact: Callers passing null (e.g., from unset XML configuration elements mapped via Plexus) crash with NPE instead of getting the default empty prefix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingjavaPull requests that update Java codepriority:minorMinor loss of function, or other problem where easy workaround is present

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions