SOLR-12813 followup -- preserve user Principal in alternate codepath in EmbeddedSolrServer #2429
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.
https://issues.apache.org/jira/browse/SOLR-12813
Description
This is a followup to a previous PR that fixed SOLR-12813.
This current change is intended as proactive code cleanup and is not needed for resolving the issue described in SOLR-12813, which was fully resolved by the previous PR.
EmbeddedSolrServer#request() has two separate places where the _parser.buildRequestFrom() utility method is called.
The first codepath is active when the
coreContainer.getRequestHandler(path)
returns non-null, which is to say that we're able to retrieve the designated SolrRequestHandler by looking it up on the available CoreContainer.The second codepath is active when
coreContainer.getRequestHandler(path)
return null and instead we need to retrieve the SolrCore from the CoreContainer and get the SolrRequestHandler from that SolrCore. This second codepath is the one that's used in subquery execution. It was updated in the initial fix for SOLR-12813 so that the call to _parser.buildRequestFrom() would now include the user Principal.However, the first codepath was left alone because it was not found to be involved in subquery execution. In the present PR, the first codepath is being updated as well, in the interest of keeping the logic as consistent as possible across the two codepaths in EmbeddedSolrServer.request()
Solution
N/A
Tests
I am looking for advice on how to create a test for this change. I believe this change is non-intrusive and safe: when we pass the Principal, it will either be null, in which case the code will act the same as before -- or it will be non-null, in which case we should be passing it. However, it appears that none of the existing unit tests "care" about this change, so it would be good to create a test that targets it. I found some tests which invoke the codepath in EmbededSolrServer.request that we're modifying here, for example TestEmbeddedSolrServerAdminHandler, but they are local SolrTestCaseJ4 instances and I believe we need a SolrCloudTestCase to be able to set up security.json in zookeeper to create a meaningful test... or maybe there's an easier way? If anyone has insight on when/why one codepath would be active instead of the other -- that's to say, why a request handler would be found on the CoreContainer versus only on the SolrCore, I'm interested to know the background.
Checklist
Please review the following and check all that apply:
main
branch../gradlew check
.