Fix NPEs in SuffixMapping, SingleTargetMapping, and URLLocation - #119
Open
itsmehotpants wants to merge 1 commit into
Open
Fix NPEs in SuffixMapping, SingleTargetMapping, and URLLocation#119itsmehotpants wants to merge 1 commit into
itsmehotpants wants to merge 1 commit into
Conversation
- SuffixMapping#getTargetFiles: guard against null source/sourceSuffix
before calling String#endsWith, returning an empty result set instead
of throwing NullPointerException.
- SingleTargetMapping#getTargetFiles: same guard for the same
endsWith(null) NPE pattern.
- URLLocation#initFile: fall back to default temp-file prefix/suffix
("url" / ".tmp") when the caller passes null, instead of letting
Files.createTempFile(null, null) throw NullPointerException.
Adds regression tests for each case, matching the existing test style.
Fixes apache#93, Fixes apache#94, Fixes apache#95
elharo
requested changes
Jul 31, 2026
elharo
left a comment
Contributor
There was a problem hiding this comment.
Three issues should be three PRs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Fixes three related NullPointerException bugs:
SuffixMapping#getTargetFilesthrew NPE fromsource.endsWith(sourceSuffix)when either argument wasnull.SingleTargetMapping#getTargetFileshad the sameendsWith(null)NPE pattern.URLLocation#initFilethrew NPE fromFiles.createTempFile(tempFilePrefix, tempFileSuffix)when the prefix/suffix constructor args werenull(allowed by the public constructor).Fix
SuffixMapping/SingleTargetMapping: guard with a null check before callingendsWith, returning an empty result set (no match) instead of throwing.URLLocation: fall back to default values ("url"/".tmp") when the prefix/suffix are null, consistent with how the constructor already allows them to be null.Testing
Added regression tests for each case following the existing test style in
SuffixMappingTestandURLLocationTest.Fixes #93
Fixes #94
Fixes #95