Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SOLR-17153 Resolve IndexOutOfBoundsException #2393

Merged
merged 7 commits into from Apr 10, 2024

Conversation

aparnasuresh85
Copy link
Contributor

https://issues.apache.org/jira/browse/SOLR-17153

Description

Resolve an IndexOutOfBoundsException in HttpSolrCall.resolveDocCollection(), at line:
String collectionName = collectionsList.get(0);

Solution

Check if collectionsList is empty, in that case return early.

Tests

Please describe the tests you've developed or run to confirm this patch implements the feature or solves the problem.

Checklist

Please review the following and check all that apply:

  • I have reviewed the guidelines for How to Contribute and my code conforms to the standards described there to the best of my ability.
  • I have created a Jira issue and added the issue ID to my pull request title.
  • I have given Solr maintainers access to contribute to my PR branch. (optional but recommended)
  • I have developed this patch against the main branch.
  • I have run ./gradlew check.
  • [] I have added tests for my changes.
  • I have added documentation for the Reference Guide

Copy link
Contributor

@dsmiley dsmiley left a comment

Choose a reason for hiding this comment

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

If Eric found a bug then it seems we need a test for this bug

@aparnasuresh85
Copy link
Contributor Author

If Eric found a bug then it seems we need a test for this bug

I had the same thought. But I now see the line of code that caused it is no longer being used. The call resolveDocCollection() is now being invoked within getCoreByCollection() and its signature has also changed.

What would be the test case of the new test? We would need one that doesnt create a collection or noneof the usual ones. Eric tried to start solr and launch the admin page.....

@dsmiley
Copy link
Contributor

dsmiley commented Apr 8, 2024

That the method signature changes doesn't affect our ability to test; maybe you were thinking a unit test. I much prefer an integration test (using SolrCloudTestCase). All we need to do is figure out what URL into Solr, in what situation (a collection existing or not? time-routed-alias? To a node with a core for the collection or not?) and do the same in a test. It should fail prior to this PR.

@epugh
Copy link
Contributor

epugh commented Apr 9, 2024

I think a test of a Solr with no collections created should demonstrate the bug. Please let me know if I can help. I'd love to see this fixed so I can then merge some other code into main.

@aparnasuresh85
Copy link
Contributor Author

I think a test of a Solr with no collections created should demonstrate the bug. Please let me know if I can help. I'd love to see this fixed so I can then merge some other code into main.

Hi Eric,

I started working on a Java test which didnt really work as expected to address this use case (launch the solr admin console ). I am now looking to add a test case in a ".bats" script under solr/packaging. Let me know if this sounds appropriate.

run curl -s -o /dev/null -w "%{http_code}" http://localhost:${SOLR_PORT}/solr/

# Check if the HTTP response code is 200 (OK)
assert_output --partial "200"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The test failed with the bug and passed without it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is the --partial part accurate -- won't 200 be the entirety of the output?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I modified the test to instead match exact output.

@aparnasuresh85
Copy link
Contributor Author

I think a test of a Solr with no collections created should demonstrate the bug. Please let me know if I can help. I'd love to see this fixed so I can then merge some other code into main.

Hi @epugh , @dsmiley ,

I have updated the PR with a .bats test. Please let me know your feedback.

Copy link
Contributor

Choose a reason for hiding this comment

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

lets just call it test_adminconsole_urls.bats so that we leave room and encourage additional URLs to fetch that the admin console fetches. Even a TODO comment would encourage this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

run curl -s -o /dev/null -w "%{http_code}" http://localhost:${SOLR_PORT}/solr/

# Check if the HTTP response code is 200 (OK)
assert_output --partial "200"
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the --partial part accurate -- won't 200 be the entirety of the output?

@dsmiley
Copy link
Contributor

dsmiley commented Apr 10, 2024

Looks good; I'd like to merge. If you disagree @epugh , please pipe in today.

Minor nitpick: there's a comment that doesn't flow (newline) nicely but whatever.

@epugh
Copy link
Contributor

epugh commented Apr 10, 2024

I just manually gave this PR a run through, and it looks great. Please merge!

@dsmiley dsmiley merged commit 09e8d0c into apache:main Apr 10, 2024
5 checks passed
dsmiley pushed a commit that referenced this pull request Apr 10, 2024
Resolve IndexOutOfBoundsException, a regression from the first change in this issue.

* Call resolveDocCollection inside getCoreByCollection
* New BATS test to check URLs that the Solr Admin UI (or a user trying to navigate to such) might use

(cherry picked from commit 09e8d0c)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants