Skip to content

fix #87: null-check getTargetFiles() return value - #102

Open
elharo wants to merge 2 commits into
apache:masterfrom
elharo:fix-87-staleresourcescanner-npe
Open

fix #87: null-check getTargetFiles() return value#102
elharo wants to merge 2 commits into
apache:masterfrom
elharo:fix-87-staleresourcescanner-npe

Conversation

@elharo

@elharo elharo commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Skip SourceMapping entries that return null from getTargetFiles() instead of throwing NPE.

Fixes #87

- Skip mappings that return null from getTargetFiles()
- Add test for null return from SourceMapping
@elharo
elharo marked this pull request as ready for review August 1, 2026 11:17
@elharo
elharo requested a review from Copilot August 1, 2026 11:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes an NPE in StaleResourceScanner by tolerating SourceMapping#getTargetFiles(...) implementations that return null, aligning behavior with Issue #87’s reported failure mode.

Changes:

  • Add a null-check in StaleResourceScanner#getIncludedSources(...) to skip mappings that return null from getTargetFiles().
  • Add a JUnit test covering the “getTargetFiles() returns null” scenario to prevent regressions.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/main/java/org/apache/maven/shared/io/scan/StaleResourceScanner.java Skips SourceMapping entries that return null target file sets, preventing NPE during iteration.
src/test/java/org/apache/maven/shared/io/scan/StaleResourceScannerTest.java Adds a regression test exercising the null-return behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

StaleResourceScanner: NPE when SourceMapping.getTargetFiles() returns null

2 participants