Fix NullPointerException in SuffixMapping.getTargetFiles - #108
Open
JRVector9 wants to merge 1 commit into
Open
Conversation
source.endsWith(sourceSuffix) throws NPE when either source or sourceSuffix is null, both of which are reachable through the public constructor. Guard the call and treat a null source or suffix as a non-match, consistent with how other SourceMapping implementations handle non-matching input. Adds two tests that reproduce the NPE before the fix. Fixes apache#93
elharo
requested changes
Jul 20, 2026
elharo
left a comment
Contributor
There was a problem hiding this comment.
I suspect the correct fix is to throw NullPointerExceptions from the constructor. What does a null suffix mean?
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.
SuffixMapping.getTargetFiles()callssource.endsWith(sourceSuffix)unconditionally. BothsourceandsourceSuffixcan be null through the public constructor (SuffixMapping(String sourceSuffix, String targetSuffix)takes no null checks), and either one being null throws an NPE:Fixes #93
Changes
endsWithcall so a nullsourceorsourceSuffixis treated as a non-match (returns an empty target set), matching the existing behavior for a suffix mismatch.shouldReturnNoTargetFilesWhenSourceSuffixIsNull,shouldReturnNoTargetFilesWhenSourceIsNull) that reproduce the NPE before the fix and pass after it.mvn test -Dtest=SuffixMappingTestandmvn verifypass locally.