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-17390: EmbeddedSolrServer now considers the ResponseParser #2774

Merged
merged 4 commits into from
Nov 4, 2024

Conversation

dsmiley
Copy link
Contributor

@dsmiley dsmiley commented Oct 17, 2024

  • Moved HttpSolrCall.getResponseWriter to SolrQueryRequest
  • Subtle improvements to make ContentStream work when they might not have

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

* Moved HttpSolrCall.getResponseWriter to SolrQueryRequest
* Subtle improvements to make ContentStream work when they might not have
@@ -934,13 +934,7 @@ protected void logAndFlushAdminRequest(SolrQueryResponse solrResp) throws IOExce
* returns the default query response writer Note: This method must not return null
*/
protected QueryResponseWriter getResponseWriter() {
String wt = solrReq.getParams().get(CommonParams.WT);
Copy link
Contributor

Choose a reason for hiding this comment

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

I love this werid logic being removed!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it has moved:

Moved HttpSolrCall.getResponseWriter to SolrQueryRequest

It wasn't specific to HTTP; EmbeddedSolrServer needs to call the same logic.

Copy link
Contributor Author

@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.

Suggested CHANGES.txt under Improvements: "EmbeddedSolrServer now considers the ResponseParser". Debatably could be in "Other" since it's basically just tests that will use it but in theory anyone might use EmbeddedSolrServer for embedding Solr.

Comment on lines -220 to +222
_parser.buildRequestFrom(
core, params, getContentStreams(request), request.getUserPrincipal());
core.getSolrConfig()
.getRequestParsers()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Using a SolrCore's SolrRequestParsers instance instead of a default one on this class means we work with parsers and configuration specific to the core. This was previously simply overlooked.

req.getContext().put(PATH, path);
req.getContext().put("httpMethod", request.getMethod().name());
SolrQueryResponse rsp = new SolrQueryResponse();
SolrRequestInfo.setRequestInfo(new SolrRequestInfo(req, rsp));

core.execute(handler, req, rsp);
checkForExceptions(rsp);

// Check if this should stream results
if (request.getStreamingResponseCallback() != null) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

moved to writeResponse and simplified a little

if (request instanceof ContentStreamUpdateRequest) {
final ContentStreamUpdateRequest csur = (ContentStreamUpdateRequest) request;
final Collection<ContentStream> cs = csur.getContentStreams();
if (cs != null) return new HashSet<>(cs);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Set didn't make sense

@@ -250,7 +250,8 @@ public final T process(SolrClient client, String collection)
throws SolrServerException, IOException {
long startNanos = System.nanoTime();
T res = createResponse(client);
res.setResponse(client.request(this, collection));
var namedList = client.request(this, collection);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

put on its own line to help debugger step-in. I've meant to do this for years.

if (random().nextBoolean()) {
CLIENT = JSR.newClient();
} else {
CLIENT = new EmbeddedSolrServer(JSR.getCoreContainer(), null);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

it works; I re-rean the test enough times to see it does, with code coverage. Not in this PR, I also played with flipping SolrTestCaseHS and some other ZK endpoint test, which helped improve this PR by uncovering things, but those changes seemed like too much scope right now.

@dsmiley
Copy link
Contributor Author

dsmiley commented Oct 30, 2024

Will merge in a couple days if no review.

@dsmiley dsmiley merged commit c5c538a into apache:main Nov 4, 2024
4 checks passed
@dsmiley dsmiley deleted the solr17390 branch November 4, 2024 22:45
dsmiley added a commit that referenced this pull request Nov 4, 2024
And
* Moved HttpSolrCall.getResponseWriter to SolrQueryRequest
* Subtle improvements to make ContentStream work when they might not have

(cherry picked from commit c5c538a)
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.

3 participants