Skip to content

Fix #135: avoid NPE in JarVersionedRuntimes.getJarClasses for missing version - #157

Open
elharo wants to merge 1 commit into
masterfrom
fix/issue-135-getjarclasses-npe
Open

Fix #135: avoid NPE in JarVersionedRuntimes.getJarClasses for missing version#157
elharo wants to merge 1 commit into
masterfrom
fix/issue-135-getjarclasses-npe

Conversation

@elharo

@elharo elharo commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Fixes #135

JarVersionedRuntimes.getJarClasses(Integer version) called versionedRuntimeMap.get(version).getJarClasses(), which throws a NullPointerException when the requested version is not a key in the map. This is inconsistent with getJarVersionedRuntime(), which safely returns null for missing keys.

This change guards against a missing key and returns null, matching the documented behaviour of the sibling accessor.

Added a unit test JarVersionedRuntimesTest that reproduces the NPE (fails before the fix, passes after):

  • getJarClassesForExistingVersion verifies the existing key still returns the expected JarClasses
  • getJarClassesForMissingVersionReturnsNull verifies a missing version returns null instead of throwing

@elharo elharo added the bug Something isn't working label Aug 7, 2026
@elharo
elharo requested review from MartinKanters and laeubi August 7, 2026 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

getJarClasses() throws NPE for missing version key in JarVersionedRuntimes

1 participant