Skip to content

SOLR-18092: fix solr-test-framework for 3rd party -- ExternalPaths NPE#4225

Open
dweiss wants to merge 3 commits intoapache:mainfrom
dweiss:npe-on-init
Open

SOLR-18092: fix solr-test-framework for 3rd party -- ExternalPaths NPE#4225
dweiss wants to merge 3 commits intoapache:mainfrom
dweiss:npe-on-init

Conversation

@dweiss
Copy link
Contributor

@dweiss dweiss commented Mar 18, 2026

The order of arguments in the loop is not right.

Copy link
Contributor

@epugh epugh left a comment

Choose a reason for hiding this comment

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

Lgtm.

@dsmiley dsmiley requested a review from Copilot March 18, 2026 23:51
Copy link
Contributor

Copilot AI left a comment

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 intends to prevent a null-pointer failure during ExternalPaths initialization when the Solr source/test base directory can’t be determined (e.g., when tests.src.home isn’t provided and the expected directories don’t exist).

Changes:

  • Fixes the short-circuit evaluation order in the directory-walk loop so base is checked for null before calling base.resolve(...).

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


Path base = file.toAbsolutePath();
while (!Files.exists(base.resolve("solr/test-framework/build.gradle")) && null != base) {
while (null != base && !Files.exists(base.resolve("solr/test-framework/build.gradle"))) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Copilot is right!
And furthermore, SolrTestCase references these constants in a way that will also NPE

@dsmiley
Copy link
Contributor

dsmiley commented Mar 23, 2026

@epugh
Copy link
Contributor

epugh commented Mar 23, 2026

I didn't realize that this bug that I ran into separately was already fixed, even though I reviewed it just a day before!!!

@dsmiley
Copy link
Contributor

dsmiley commented Mar 23, 2026

FYI my PR focused on testing this is #4227 and it includes a more expanded fix and another fix for the pom version ambiguity issue. It's still Draft/WIP. I'd rather separate the fixes of both problems and merge them before finally the test. I'll commit to this PR to take my edits from that one.

@dsmiley dsmiley changed the title Fix NPE on class init if solr tests base is not provided (and doesn't exist). SOLR-18171: fix solr-test-framework for 3rd party -- ExternalPaths NPE Mar 23, 2026
@dsmiley dsmiley changed the title SOLR-18171: fix solr-test-framework for 3rd party -- ExternalPaths NPE SOLR-18092: fix solr-test-framework for 3rd party -- ExternalPaths NPE Mar 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants