apache / apache/maven-shared-jar

getJarClasses() throws NPE for missing version key in JarVersionedRuntimes

Open
#135 0 comments 0 reactions 1 assignee Claimed by @elharo View on GitHub
bug priority:minor
Dominant language
Java
Stars
4
Forks
9
Avg merge
2h 46m
Merged PRs (30d)
3

Description

In `JarVersionedRuntimes.java:47-49`:

```java
public JarClasses getJarClasses(Integer version) {
return versionedRuntimeMap.get(version).getJarClasses(); // NPE if version absent
}
```

If the requested `version` is not a key in the map, `get(version)` returns `null`, then `.getJarClasses()` throws a NullPointerException. This is inconsistent with `getJarVersionedRuntime()` on the same class, which safely returns `null` for missing keys. Any caller querying a non-existent version will crash.

**Fix**: Guard against null, e.g.:
```java
JarVersionedRuntime runtime = versionedRuntimeMap.get(version);
return runtime != null ? runtime.getJarClasses() : null;
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.