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
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -580,12 +580,7 @@ public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throw
// If things are not tolerant, abort everything and rethrow
if (!tolerant) {
shardHandler1.cancelAll();
if (srsp.getException() instanceof SolrException) {
throw (SolrException) srsp.getException();
} else {
throw new SolrException(
SolrException.ErrorCode.SERVER_ERROR, srsp.getException());
}
throwSolrException(srsp.getException());
} else {
// Check if the purpose includes 'PURPOSE_GET_TOP_IDS'
boolean includesTopIdsPurpose =
Expand All @@ -598,7 +593,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();
throwSolrException(srsp.getException());
} else {
rsp.getResponseHeader()
.asShallowMap()
Expand Down Expand Up @@ -663,6 +658,14 @@ public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throw
}
}

private static void throwSolrException(Throwable shardResponseException) throws SolrException {
if (shardResponseException instanceof SolrException) {
throw (SolrException) shardResponseException;
} else {
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, shardResponseException);
}
}

private void tagRequestWithRequestId(ResponseBuilder rb) {
final boolean ridTaggingDisabled =
rb.req.getParams().getBool(CommonParams.DISABLE_REQUEST_ID, DISABLE_REQUEST_ID_DEFAULT);
Expand Down