Skip to content

NPE in ToolchainsRequirement.getParams() when type is not found #169

Description

@elharo

Summary

throws when called with a type that is not present in the toolchains map, instead of returning an empty map or null gracefully.

Location

https://github.com/apache/maven-toolchains-plugin/blob/master/src/main/java/org/apache/maven/plugins/toolchain/ToolchainsRequirement.java#L42-L44

Code

Problem

If is not a key in the map, returns , and throws .

Currently this is only called from with types from , which in turn originates from the entry set keys, so the current callers are safe. However, this is a fragile public API that will break if called with an unknown type.

Impact

Any future or external caller passing a non-existent type will get an unexpected NPE instead of a gracefully handled missing key.

Suggested Fix

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions