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-17053: Address ClassCastException issue #2123

Merged
merged 4 commits into from Dec 7, 2023

Conversation

aparnasuresh85
Copy link
Contributor

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

Description

Please provide a short description of the changes you're making with this pull request.
Address a ClassCastException issue in the event exception in shard response is not of type org.apache.solr.common.SolrException

Solution

Please provide a short description of the approach taken to implement your solution.
Wrap the exception in shard response into org.apache.solr.common.SolrException and throw the same

Tests

Please describe the tests you've developed or run to confirm this patch implements the feature or solves the problem.
Tests checked in as part of previous PR here: #2102. Did not introduce additional testing with this PR as it is a minor change

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

@@ -598,7 +598,7 @@ public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throw
boolean allShardsFailed = includesTopIdsPurpose && allResponsesHaveExceptions;
// if all shards fail, fail the request despite shards.tolerant
if (allShardsFailed) {
throw (SolrException) srsp.getException();
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, srsp.getException());
Copy link
Member

Choose a reason for hiding this comment

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

Can the exception be anything other than a server error? Should we do something like here

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree completely @tflobbe ; this is what I mentioned internally :-). Perhaps create a little utility method here for this pattern used twice.

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 have addressed this in my recent commit

@@ -663,6 +659,15 @@ public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throw
}
}

public static void throwSolrException(Throwable shardResponseException) throws SolrException {
Copy link
Member

Choose a reason for hiding this comment

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

Any reason to make this public?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Missed on reviewing the change myself. Updated to private.

Copy link
Member

@tflobbe tflobbe left a comment

Choose a reason for hiding this comment

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

LGTM. I guess we don't need a CHANGES entry since this is a fix to an unreleased feature

@tflobbe tflobbe merged commit 5f67d4a into apache:main Dec 7, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants