Skip to content

normalizeJavaVersion has brittle length == 3 guard #373

Description

@elharo

Affected version: 4.0.0-beta-5+

Description:

BuildHelper.normalizeJavaVersion() at line 67 checks jdk.length() == 3 before checking against the list of known 1.x versions:

public static String normalizeJavaVersion(String jdk) {
    if (jdk != null
            && jdk.length() == 3
            && Arrays.asList("1.5", "1.6", "1.7", "1.8").contains(jdk)) {
        jdk = jdk.substring(2);
    }
    return jdk;
}

The length == 3 check is redundant with the contains() call (all items in the list are length 3), but it creates an invisible coupling: if someone ever adds a version like "1.10" (length 4) to the list, the normalization would silently skip it even though it should be stripped to "10". This makes the code fragile against future maintenance.

Low priority — only a concern if Java versioning changes format.

Metadata

Metadata

Assignees

No one assigned

    Labels

    maintenancepriority: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