You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "JRVector9 (via GitHub)" <gi...@apache.org> on 2026/07/06 07:03:23 UTC

[PR] Fix NullPointerException in SuffixMapping.getTargetFiles [maven-shared-io]

JRVector9 opened a new pull request, #108:
URL: https://github.com/apache/maven-shared-io/pull/108

   `SuffixMapping.getTargetFiles()` calls `source.endsWith(sourceSuffix)` unconditionally. Both `source` and `sourceSuffix` can be null through the public constructor (`SuffixMapping(String sourceSuffix, String targetSuffix)` takes no null checks), and either one being null throws an NPE:
   
   ```
   java.lang.NullPointerException: Cannot invoke "String.endsWith(String)" because "source" is null
   	at org.apache.maven.shared.io.scan.mapping.SuffixMapping.getTargetFiles(SuffixMapping.java:59)
   
   java.lang.NullPointerException: Cannot invoke "String.length()" because "suffix" is null
   	at java.base/java.lang.String.endsWith(String.java:2331)
   	at org.apache.maven.shared.io.scan.mapping.SuffixMapping.getTargetFiles(SuffixMapping.java:59)
   ```
   
   Fixes #93
   
   ### Changes
   
   - Guard the `endsWith` call so a null `source` or `sourceSuffix` is treated as a non-match (returns an empty target set), matching the existing behavior for a suffix mismatch.
   - Added two tests (`shouldReturnNoTargetFilesWhenSourceSuffixIsNull`, `shouldReturnNoTargetFilesWhenSourceIsNull`) that reproduce the NPE before the fix and pass after it.
   
   `mvn test -Dtest=SuffixMappingTest` and `mvn verify` pass locally.
   
   - [x] I hereby declare this contribution to be licenced under the [Apache License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix NullPointerException in SuffixMapping.getTargetFiles [maven-shared-io]

Posted by "slachiewicz (via GitHub)" <gi...@apache.org>.
slachiewicz closed pull request #108: Fix NullPointerException in SuffixMapping.getTargetFiles
URL: https://github.com/apache/maven-shared-io/pull/108


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org