[Rename] ElasticsearchStatusException in server module (#172)
This commit refactors the ElasticsearchStatusException in the server module to OpenSearchStatusException. References and usages throughout the rest of the codebase are fully refactored. Signed-off-by: Nicholas Knize <nknize@amazon.com>
This commit is contained in:
parent
1015c8e609
commit
64d7e7e9ca
|
@ -21,7 +21,7 @@ package org.elasticsearch.client;
|
|||
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.elasticsearch.OpenSearchException;
|
||||
import org.elasticsearch.ElasticsearchStatusException;
|
||||
import org.elasticsearch.OpenSearchStatusException;
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.ActionRequest;
|
||||
import org.elasticsearch.action.ActionRequestValidationException;
|
||||
|
@ -1688,29 +1688,29 @@ public class RestHighLevelClient implements Closeable {
|
|||
/**
|
||||
* Converts a {@link ResponseException} obtained from the low level REST client into an {@link OpenSearchException}.
|
||||
* If a response body was returned, tries to parse it as an error returned from Elasticsearch.
|
||||
* If no response body was returned or anything goes wrong while parsing the error, returns a new {@link ElasticsearchStatusException}
|
||||
* If no response body was returned or anything goes wrong while parsing the error, returns a new {@link OpenSearchStatusException}
|
||||
* that wraps the original {@link ResponseException}. The potential exception obtained while parsing is added to the returned
|
||||
* exception as a suppressed exception. This method is guaranteed to not throw any exception eventually thrown while parsing.
|
||||
*/
|
||||
protected final ElasticsearchStatusException parseResponseException(ResponseException responseException) {
|
||||
protected final OpenSearchStatusException parseResponseException(ResponseException responseException) {
|
||||
Response response = responseException.getResponse();
|
||||
HttpEntity entity = response.getEntity();
|
||||
ElasticsearchStatusException elasticsearchException;
|
||||
OpenSearchStatusException opensearchException;
|
||||
RestStatus restStatus = RestStatus.fromCode(response.getStatusLine().getStatusCode());
|
||||
|
||||
if (entity == null) {
|
||||
elasticsearchException = new ElasticsearchStatusException(
|
||||
opensearchException = new OpenSearchStatusException(
|
||||
responseException.getMessage(), restStatus, responseException);
|
||||
} else {
|
||||
try {
|
||||
elasticsearchException = parseEntity(entity, BytesRestResponse::errorFromXContent);
|
||||
elasticsearchException.addSuppressed(responseException);
|
||||
opensearchException = parseEntity(entity, BytesRestResponse::errorFromXContent);
|
||||
opensearchException.addSuppressed(responseException);
|
||||
} catch (Exception e) {
|
||||
elasticsearchException = new ElasticsearchStatusException("Unable to parse response body", restStatus, responseException);
|
||||
elasticsearchException.addSuppressed(e);
|
||||
opensearchException = new OpenSearchStatusException("Unable to parse response body", restStatus, responseException);
|
||||
opensearchException.addSuppressed(e);
|
||||
}
|
||||
}
|
||||
return elasticsearchException;
|
||||
return opensearchException;
|
||||
}
|
||||
|
||||
protected final <Resp> Resp parseEntity(final HttpEntity entity,
|
||||
|
|
|
@ -21,7 +21,7 @@ package org.elasticsearch.client;
|
|||
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.elasticsearch.OpenSearchException;
|
||||
import org.elasticsearch.ElasticsearchStatusException;
|
||||
import org.elasticsearch.OpenSearchStatusException;
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest;
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
|
||||
import org.elasticsearch.action.admin.cluster.settings.ClusterGetSettingsRequest;
|
||||
|
@ -387,7 +387,7 @@ public class ClusterClientIT extends ESRestHighLevelClientTestCase {
|
|||
highLevelClient().cluster()::deleteComponentTemplateAsync);
|
||||
assertThat(response.isAcknowledged(), equalTo(true));
|
||||
|
||||
ElasticsearchStatusException statusException = expectThrows(ElasticsearchStatusException.class,
|
||||
OpenSearchStatusException statusException = expectThrows(OpenSearchStatusException.class,
|
||||
() -> execute(getComponentTemplatesRequest,
|
||||
highLevelClient().cluster()::getComponentTemplate, highLevelClient().cluster()::getComponentTemplateAsync));
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
package org.elasticsearch.client;
|
||||
|
||||
import org.elasticsearch.OpenSearchException;
|
||||
import org.elasticsearch.ElasticsearchStatusException;
|
||||
import org.elasticsearch.OpenSearchStatusException;
|
||||
import org.elasticsearch.action.DocWriteRequest;
|
||||
import org.elasticsearch.action.DocWriteResponse;
|
||||
import org.elasticsearch.action.bulk.BulkItemResponse;
|
||||
|
@ -146,7 +146,7 @@ public class CrudIT extends ESRestHighLevelClientTestCase {
|
|||
highLevelClient().index(
|
||||
new IndexRequest("index").id(docId).source(Collections.singletonMap("foo", "bar"))
|
||||
.versionType(VersionType.EXTERNAL).version(12), RequestOptions.DEFAULT);
|
||||
ElasticsearchStatusException exception = expectThrows(ElasticsearchStatusException.class, () -> {
|
||||
OpenSearchStatusException exception = expectThrows(OpenSearchStatusException.class, () -> {
|
||||
DeleteRequest deleteRequest = new DeleteRequest("index", docId).versionType(VersionType.EXTERNAL).version(10);
|
||||
execute(deleteRequest, highLevelClient()::delete, highLevelClient()::deleteAsync);
|
||||
});
|
||||
|
@ -594,7 +594,7 @@ public class CrudIT extends ESRestHighLevelClientTestCase {
|
|||
assertEquals("id", indexResponse.getId());
|
||||
assertEquals(2L, indexResponse.getVersion());
|
||||
|
||||
ElasticsearchStatusException exception = expectThrows(ElasticsearchStatusException.class, () -> {
|
||||
OpenSearchStatusException exception = expectThrows(OpenSearchStatusException.class, () -> {
|
||||
IndexRequest wrongRequest = new IndexRequest("index").id("id");
|
||||
wrongRequest.source(XContentBuilder.builder(xContentType.xContent()).startObject().field("field", "test").endObject());
|
||||
wrongRequest.setIfSeqNo(1L).setIfPrimaryTerm(5L);
|
||||
|
@ -608,7 +608,7 @@ public class CrudIT extends ESRestHighLevelClientTestCase {
|
|||
assertEquals("index", exception.getMetadata("es.index").get(0));
|
||||
}
|
||||
{
|
||||
ElasticsearchStatusException exception = expectThrows(ElasticsearchStatusException.class, () -> {
|
||||
OpenSearchStatusException exception = expectThrows(OpenSearchStatusException.class, () -> {
|
||||
IndexRequest indexRequest = new IndexRequest("index").id("missing_pipeline");
|
||||
indexRequest.source(XContentBuilder.builder(xContentType.xContent()).startObject().field("field", "test").endObject());
|
||||
indexRequest.setPipeline("missing");
|
||||
|
@ -644,7 +644,7 @@ public class CrudIT extends ESRestHighLevelClientTestCase {
|
|||
assertEquals("_doc", indexResponse.getType());
|
||||
assertEquals("with_create_op_type", indexResponse.getId());
|
||||
|
||||
ElasticsearchStatusException exception = expectThrows(ElasticsearchStatusException.class, () -> {
|
||||
OpenSearchStatusException exception = expectThrows(OpenSearchStatusException.class, () -> {
|
||||
execute(indexRequest, highLevelClient()::index, highLevelClient()::indexAsync);
|
||||
});
|
||||
|
||||
|
@ -675,7 +675,7 @@ public class CrudIT extends ESRestHighLevelClientTestCase {
|
|||
UpdateRequest updateRequest = new UpdateRequest("index", "does_not_exist");
|
||||
updateRequest.doc(singletonMap("field", "value"), randomFrom(XContentType.values()));
|
||||
|
||||
ElasticsearchStatusException exception = expectThrows(ElasticsearchStatusException.class, () ->
|
||||
OpenSearchStatusException exception = expectThrows(OpenSearchStatusException.class, () ->
|
||||
execute(updateRequest, highLevelClient()::update, highLevelClient()::updateAsync));
|
||||
assertEquals(RestStatus.NOT_FOUND, exception.status());
|
||||
assertEquals("Elasticsearch exception [type=document_missing_exception, reason=[_doc][does_not_exist]: document missing]",
|
||||
|
@ -712,7 +712,7 @@ public class CrudIT extends ESRestHighLevelClientTestCase {
|
|||
updateRequest.setIfSeqNo(lastUpdateSeqNo + (randomBoolean() ? 0 : 1));
|
||||
updateRequest.setIfPrimaryTerm(lastUpdatePrimaryTerm + 1);
|
||||
}
|
||||
ElasticsearchStatusException exception = expectThrows(ElasticsearchStatusException.class, () ->
|
||||
OpenSearchStatusException exception = expectThrows(OpenSearchStatusException.class, () ->
|
||||
execute(updateRequest, highLevelClient()::update, highLevelClient()::updateAsync));
|
||||
assertEquals(exception.toString(),RestStatus.CONFLICT, exception.status());
|
||||
assertThat(exception.getMessage(), containsString("Elasticsearch exception [type=version_conflict_engine_exception"));
|
||||
|
|
|
@ -23,7 +23,7 @@ import org.apache.http.client.methods.HttpGet;
|
|||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.client.methods.HttpPut;
|
||||
import org.elasticsearch.OpenSearchException;
|
||||
import org.elasticsearch.ElasticsearchStatusException;
|
||||
import org.elasticsearch.OpenSearchStatusException;
|
||||
import org.elasticsearch.action.admin.indices.alias.Alias;
|
||||
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest;
|
||||
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest.AliasActions;
|
||||
|
@ -826,7 +826,7 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
|
|||
IndicesAliasesRequest mixedRequest = new IndicesAliasesRequest();
|
||||
mixedRequest.addAliasAction(new AliasActions(AliasActions.Type.ADD).indices(index).aliases(alias));
|
||||
mixedRequest.addAliasAction(new AliasActions(AliasActions.Type.REMOVE).indices(nonExistentIndex).alias(alias));
|
||||
exception = expectThrows(ElasticsearchStatusException.class,
|
||||
exception = expectThrows(OpenSearchStatusException.class,
|
||||
() -> execute(mixedRequest, highLevelClient().indices()::updateAliases, highLevelClient().indices()::updateAliasesAsync));
|
||||
assertThat(exception.status(), equalTo(RestStatus.NOT_FOUND));
|
||||
assertThat(exception.getMessage(),
|
||||
|
@ -1651,7 +1651,7 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
|
|||
.alias(new Alias("alias-1").indexRouting("abc")).alias(new Alias("{index}-write").searchRouting("xyz"));
|
||||
|
||||
|
||||
ElasticsearchStatusException badMappingError = expectThrows(ElasticsearchStatusException.class,
|
||||
OpenSearchStatusException badMappingError = expectThrows(OpenSearchStatusException.class,
|
||||
() -> execute(putTemplateRequest,
|
||||
highLevelClient().indices()::putTemplate, highLevelClient().indices()::putTemplateAsync));
|
||||
assertThat(badMappingError.getDetailedMessage(),
|
||||
|
@ -1719,7 +1719,7 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
|
|||
PutIndexTemplateRequest unknownSettingTemplate = new PutIndexTemplateRequest("t3")
|
||||
.patterns(Collections.singletonList("any"))
|
||||
.settings(Settings.builder().put("this-setting-does-not-exist", 100));
|
||||
ElasticsearchStatusException unknownSettingError = expectThrows(ElasticsearchStatusException.class,
|
||||
OpenSearchStatusException unknownSettingError = expectThrows(OpenSearchStatusException.class,
|
||||
() -> execute(unknownSettingTemplate, client.indices()::putTemplate, client.indices()::putTemplateAsync));
|
||||
assertThat(unknownSettingError.getDetailedMessage(), containsString("unknown setting [index.this-setting-does-not-exist]"));
|
||||
}
|
||||
|
@ -2077,7 +2077,7 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
|
|||
|
||||
getDataStreamRequest = new GetDataStreamRequest(dataStreamName);
|
||||
GetDataStreamRequest finalGetDataStreamRequest = getDataStreamRequest;
|
||||
ElasticsearchStatusException e = expectThrows(ElasticsearchStatusException.class, () -> execute(finalGetDataStreamRequest,
|
||||
OpenSearchStatusException e = expectThrows(OpenSearchStatusException.class, () -> execute(finalGetDataStreamRequest,
|
||||
indices::getDataStream, indices::getDataStreamAsync));
|
||||
assertThat(e.status(), equalTo(RestStatus.NOT_FOUND));
|
||||
}
|
||||
|
@ -2117,7 +2117,7 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
|
|||
highLevelClient().indices()::deleteIndexTemplateAsync);
|
||||
assertThat(response.isAcknowledged(), equalTo(true));
|
||||
|
||||
ElasticsearchStatusException statusException = expectThrows(ElasticsearchStatusException.class,
|
||||
OpenSearchStatusException statusException = expectThrows(OpenSearchStatusException.class,
|
||||
() -> execute(getComposableIndexTemplateRequest,
|
||||
highLevelClient().indices()::getIndexTemplate, highLevelClient().indices()::getIndexTemplateAsync));
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ package org.elasticsearch.client;
|
|||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.client.methods.HttpPut;
|
||||
import org.elasticsearch.OpenSearchException;
|
||||
import org.elasticsearch.ElasticsearchStatusException;
|
||||
import org.elasticsearch.OpenSearchStatusException;
|
||||
import org.elasticsearch.action.explain.ExplainRequest;
|
||||
import org.elasticsearch.action.explain.ExplainResponse;
|
||||
import org.elasticsearch.action.fieldcaps.FieldCapabilities;
|
||||
|
@ -340,7 +340,7 @@ public class SearchIT extends ESRestHighLevelClientTestCase {
|
|||
searchSourceBuilder.size(0);
|
||||
searchRequest.source(searchSourceBuilder);
|
||||
|
||||
ElasticsearchStatusException exception = expectThrows(ElasticsearchStatusException.class,
|
||||
OpenSearchStatusException exception = expectThrows(OpenSearchStatusException.class,
|
||||
() -> execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync));
|
||||
assertEquals(RestStatus.BAD_REQUEST, exception.status());
|
||||
}
|
||||
|
@ -722,7 +722,7 @@ public class SearchIT extends ESRestHighLevelClientTestCase {
|
|||
assertTrue(clearScrollResponse.isSucceeded());
|
||||
|
||||
SearchScrollRequest scrollRequest = new SearchScrollRequest(searchResponse.getScrollId()).scroll(TimeValue.timeValueMinutes(2));
|
||||
ElasticsearchStatusException exception = expectThrows(ElasticsearchStatusException.class, () -> execute(scrollRequest,
|
||||
OpenSearchStatusException exception = expectThrows(OpenSearchStatusException.class, () -> execute(scrollRequest,
|
||||
highLevelClient()::scroll, highLevelClient()::scrollAsync));
|
||||
assertEquals(RestStatus.NOT_FOUND, exception.status());
|
||||
assertThat(exception.getRootCause(), instanceOf(OpenSearchException.class));
|
||||
|
@ -954,7 +954,7 @@ public class SearchIT extends ESRestHighLevelClientTestCase {
|
|||
searchTemplateRequest.setScript("non-existent");
|
||||
searchTemplateRequest.setScriptParams(Collections.emptyMap());
|
||||
|
||||
ElasticsearchStatusException exception = expectThrows(ElasticsearchStatusException.class,
|
||||
OpenSearchStatusException exception = expectThrows(OpenSearchStatusException.class,
|
||||
() -> execute(searchTemplateRequest,
|
||||
highLevelClient()::searchTemplate,
|
||||
highLevelClient()::searchTemplateAsync));
|
||||
|
@ -1073,7 +1073,7 @@ public class SearchIT extends ESRestHighLevelClientTestCase {
|
|||
multiSearchTemplateRequest.add(badRequest2);
|
||||
|
||||
// The whole HTTP request should fail if no nested search requests are valid
|
||||
ElasticsearchStatusException exception = expectThrows(ElasticsearchStatusException.class,
|
||||
OpenSearchStatusException exception = expectThrows(OpenSearchStatusException.class,
|
||||
() -> execute(multiSearchTemplateRequest, highLevelClient()::msearchTemplate,
|
||||
highLevelClient()::msearchTemplateAsync));
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ package org.elasticsearch.client;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.elasticsearch.ElasticsearchStatusException;
|
||||
import org.elasticsearch.OpenSearchStatusException;
|
||||
import org.elasticsearch.action.admin.cluster.storedscripts.DeleteStoredScriptRequest;
|
||||
import org.elasticsearch.action.admin.cluster.storedscripts.GetStoredScriptRequest;
|
||||
import org.elasticsearch.action.admin.cluster.storedscripts.GetStoredScriptResponse;
|
||||
|
@ -76,7 +76,7 @@ public class StoredScriptsIT extends ESRestHighLevelClientTestCase {
|
|||
|
||||
GetStoredScriptRequest getRequest = new GetStoredScriptRequest(id);
|
||||
|
||||
final ElasticsearchStatusException statusException = expectThrows(ElasticsearchStatusException.class,
|
||||
final OpenSearchStatusException statusException = expectThrows(OpenSearchStatusException.class,
|
||||
() -> execute(getRequest, highLevelClient()::getScript,
|
||||
highLevelClient()::getScriptAsync));
|
||||
assertThat(statusException.status(), equalTo(RestStatus.NOT_FOUND));
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
*/
|
||||
package org.elasticsearch.client.indices;
|
||||
|
||||
import org.elasticsearch.ElasticsearchStatusException;
|
||||
import org.elasticsearch.OpenSearchStatusException;
|
||||
import org.elasticsearch.action.support.master.AcknowledgedResponse;
|
||||
import org.elasticsearch.action.support.master.ShardsAcknowledgedResponse;
|
||||
import org.elasticsearch.client.AbstractResponseTestCase;
|
||||
|
@ -215,7 +215,7 @@ public class CloseIndexResponseTests extends
|
|||
Exception exception = randomFrom(new IndexNotFoundException(indexName),
|
||||
new ActionNotFoundTransportException("test"),
|
||||
new IOException("boom", new NullPointerException()),
|
||||
new ElasticsearchStatusException("something", RestStatus.TOO_MANY_REQUESTS));
|
||||
new OpenSearchStatusException("something", RestStatus.TOO_MANY_REQUESTS));
|
||||
return new org.elasticsearch.action.admin.indices.close.CloseIndexResponse.ShardResult.Failure(indexName, shard, exception, nodeId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,8 +26,8 @@ import org.apache.http.util.EntityUtils;
|
|||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.logging.log4j.message.ParameterizedMessage;
|
||||
import org.apache.logging.log4j.util.Supplier;
|
||||
import org.elasticsearch.OpenSearchException;
|
||||
import org.elasticsearch.ElasticsearchStatusException;
|
||||
import org.elasticsearch.OpenSearchException;;
|
||||
import org.elasticsearch.OpenSearchStatusException;
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.action.bulk.BackoffPolicy;
|
||||
import org.elasticsearch.action.search.SearchRequest;
|
||||
|
@ -230,7 +230,7 @@ public class RemoteScrollableHitSource extends ScrollableHitSource {
|
|||
* not have a constant for the status code so in that case we just use 500 instead. We also extract make sure to include the response
|
||||
* body in the message so the user can figure out *why* the remote Elasticsearch service threw the error back to us.
|
||||
*/
|
||||
static ElasticsearchStatusException wrapExceptionToPreserveStatus(int statusCode, @Nullable HttpEntity entity, Exception cause) {
|
||||
static OpenSearchStatusException wrapExceptionToPreserveStatus(int statusCode, @Nullable HttpEntity entity, Exception cause) {
|
||||
RestStatus status = RestStatus.fromCode(statusCode);
|
||||
String messagePrefix = "";
|
||||
if (status == null) {
|
||||
|
@ -238,9 +238,9 @@ public class RemoteScrollableHitSource extends ScrollableHitSource {
|
|||
status = RestStatus.INTERNAL_SERVER_ERROR;
|
||||
}
|
||||
try {
|
||||
return new ElasticsearchStatusException(messagePrefix + bodyMessage(entity), status, cause);
|
||||
return new OpenSearchStatusException(messagePrefix + bodyMessage(entity), status, cause);
|
||||
} catch (IOException ioe) {
|
||||
ElasticsearchStatusException e = new ElasticsearchStatusException(messagePrefix + "Failed to extract body.", status, cause);
|
||||
OpenSearchStatusException e = new OpenSearchStatusException(messagePrefix + "Failed to extract body.", status, cause);
|
||||
e.addSuppressed(ioe);
|
||||
return e;
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ package org.elasticsearch.index.reindex;
|
|||
|
||||
import org.apache.lucene.util.SetOnce;
|
||||
import org.elasticsearch.OpenSearchSecurityException;
|
||||
import org.elasticsearch.ElasticsearchStatusException;
|
||||
import org.elasticsearch.OpenSearchStatusException;
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.ActionRequest;
|
||||
import org.elasticsearch.action.ActionResponse;
|
||||
|
@ -123,7 +123,7 @@ public class ReindexFromRemoteWithAuthTests extends ESSingleNodeTestCase {
|
|||
public void testReindexSendsHeaders() throws Exception {
|
||||
ReindexRequestBuilder request = new ReindexRequestBuilder(client(), ReindexAction.INSTANCE).source("source").destination("dest")
|
||||
.setRemoteInfo(newRemoteInfo(null, null, singletonMap(TestFilter.EXAMPLE_HEADER, "doesn't matter")));
|
||||
ElasticsearchStatusException e = expectThrows(ElasticsearchStatusException.class, () -> request.get());
|
||||
OpenSearchStatusException e = expectThrows(OpenSearchStatusException.class, () -> request.get());
|
||||
assertEquals(RestStatus.BAD_REQUEST, e.status());
|
||||
assertThat(e.getMessage(), containsString("Hurray! Sent the header!"));
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ public class ReindexFromRemoteWithAuthTests extends ESSingleNodeTestCase {
|
|||
public void testReindexWithoutAuthenticationWhenRequired() throws Exception {
|
||||
ReindexRequestBuilder request = new ReindexRequestBuilder(client(), ReindexAction.INSTANCE).source("source").destination("dest")
|
||||
.setRemoteInfo(newRemoteInfo(null, null, emptyMap()));
|
||||
ElasticsearchStatusException e = expectThrows(ElasticsearchStatusException.class, () -> request.get());
|
||||
OpenSearchStatusException e = expectThrows(OpenSearchStatusException.class, () -> request.get());
|
||||
assertEquals(RestStatus.UNAUTHORIZED, e.status());
|
||||
assertThat(e.getMessage(), containsString("\"reason\":\"Authentication required\""));
|
||||
assertThat(e.getMessage(), containsString("\"WWW-Authenticate\":\"Basic realm=auth-realm\""));
|
||||
|
@ -140,7 +140,7 @@ public class ReindexFromRemoteWithAuthTests extends ESSingleNodeTestCase {
|
|||
public void testReindexWithBadAuthentication() throws Exception {
|
||||
ReindexRequestBuilder request = new ReindexRequestBuilder(client(), ReindexAction.INSTANCE).source("source").destination("dest")
|
||||
.setRemoteInfo(newRemoteInfo("junk", "auth", emptyMap()));
|
||||
ElasticsearchStatusException e = expectThrows(ElasticsearchStatusException.class, () -> request.get());
|
||||
OpenSearchStatusException e = expectThrows(OpenSearchStatusException.class, () -> request.get());
|
||||
assertThat(e.getMessage(), containsString("\"reason\":\"Bad Authorization\""));
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ import org.apache.http.message.BasicHttpResponse;
|
|||
import org.apache.http.message.BasicStatusLine;
|
||||
import org.apache.http.nio.protocol.HttpAsyncRequestProducer;
|
||||
import org.apache.http.nio.protocol.HttpAsyncResponseConsumer;
|
||||
import org.elasticsearch.ElasticsearchStatusException;
|
||||
import org.elasticsearch.OpenSearchStatusException;
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.action.bulk.BackoffPolicy;
|
||||
import org.elasticsearch.action.search.SearchRequest;
|
||||
|
@ -381,7 +381,7 @@ public class RemoteScrollableHitSourceTests extends ESTestCase {
|
|||
|
||||
// Successfully get the status without a body
|
||||
RestStatus status = randomFrom(RestStatus.values());
|
||||
ElasticsearchStatusException wrapped = RemoteScrollableHitSource.wrapExceptionToPreserveStatus(status.getStatus(), null, cause);
|
||||
OpenSearchStatusException wrapped = RemoteScrollableHitSource.wrapExceptionToPreserveStatus(status.getStatus(), null, cause);
|
||||
assertEquals(status, wrapped.status());
|
||||
assertEquals(cause, wrapped.getCause());
|
||||
assertEquals("No error body.", wrapped.getMessage());
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
package org.elasticsearch.upgrades;
|
||||
|
||||
import org.elasticsearch.ElasticsearchStatusException;
|
||||
import org.elasticsearch.OpenSearchStatusException;
|
||||
import org.elasticsearch.action.admin.cluster.repositories.put.PutRepositoryRequest;
|
||||
import org.elasticsearch.action.admin.cluster.snapshots.delete.DeleteSnapshotRequest;
|
||||
import org.elasticsearch.action.admin.cluster.snapshots.status.SnapshotStatus;
|
||||
|
@ -221,7 +221,7 @@ public class MultiVersionRepositoryAccessIT extends ESRestTestCase {
|
|||
if (SnapshotsService.useIndexGenerations(minimumNodeVersion()) == false) {
|
||||
assertThat(TEST_STEP, is(TestStep.STEP3_OLD_CLUSTER));
|
||||
final List<Class<? extends Exception>> expectedExceptions =
|
||||
Arrays.asList(ResponseException.class, ElasticsearchStatusException.class);
|
||||
Arrays.asList(ResponseException.class, OpenSearchStatusException.class);
|
||||
expectThrowsAnyOf(expectedExceptions, () -> listSnapshots(repoName));
|
||||
expectThrowsAnyOf(expectedExceptions, () -> deleteSnapshot(client, repoName, "snapshot-1"));
|
||||
expectThrowsAnyOf(expectedExceptions, () -> deleteSnapshot(client, repoName, "snapshot-2"));
|
||||
|
|
|
@ -993,7 +993,7 @@ public class OpenSearchException extends RuntimeException implements ToXContentF
|
|||
UNKNOWN_VERSION_ADDED),
|
||||
NOT_MASTER_EXCEPTION(org.elasticsearch.cluster.NotMasterException.class, org.elasticsearch.cluster.NotMasterException::new, 144,
|
||||
UNKNOWN_VERSION_ADDED),
|
||||
STATUS_EXCEPTION(org.elasticsearch.ElasticsearchStatusException.class, org.elasticsearch.ElasticsearchStatusException::new, 145,
|
||||
STATUS_EXCEPTION(org.elasticsearch.OpenSearchStatusException.class, org.elasticsearch.OpenSearchStatusException::new, 145,
|
||||
UNKNOWN_VERSION_ADDED),
|
||||
TASK_CANCELLED_EXCEPTION(org.elasticsearch.tasks.TaskCancelledException.class,
|
||||
org.elasticsearch.tasks.TaskCancelledException::new, 146, UNKNOWN_VERSION_ADDED),
|
||||
|
|
|
@ -26,7 +26,7 @@ import java.io.IOException;
|
|||
/**
|
||||
* Generic security exception
|
||||
*/
|
||||
public class OpenSearchSecurityException extends ElasticsearchStatusException {
|
||||
public class OpenSearchSecurityException extends OpenSearchStatusException {
|
||||
/**
|
||||
* Build the exception with a specific status and cause.
|
||||
*/
|
||||
|
|
|
@ -29,13 +29,13 @@ import java.io.IOException;
|
|||
* Exception who's {@link RestStatus} is arbitrary rather than derived. Used, for example, by reindex-from-remote to wrap remote exceptions
|
||||
* that contain a status.
|
||||
*/
|
||||
public class ElasticsearchStatusException extends OpenSearchException {
|
||||
public class OpenSearchStatusException extends OpenSearchException {
|
||||
private final RestStatus status;
|
||||
|
||||
/**
|
||||
* Build the exception with a specific status and cause.
|
||||
*/
|
||||
public ElasticsearchStatusException(String msg, RestStatus status, Throwable cause, Object... args) {
|
||||
public OpenSearchStatusException(String msg, RestStatus status, Throwable cause, Object... args) {
|
||||
super(msg, cause, args);
|
||||
this.status = status;
|
||||
}
|
||||
|
@ -43,14 +43,14 @@ public class ElasticsearchStatusException extends OpenSearchException {
|
|||
/**
|
||||
* Build the exception without a cause.
|
||||
*/
|
||||
public ElasticsearchStatusException(String msg, RestStatus status, Object... args) {
|
||||
public OpenSearchStatusException(String msg, RestStatus status, Object... args) {
|
||||
this(msg, status, null, args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read from a stream.
|
||||
*/
|
||||
public ElasticsearchStatusException(StreamInput in) throws IOException {
|
||||
public OpenSearchStatusException(StreamInput in) throws IOException {
|
||||
super(in);
|
||||
status = RestStatus.readFrom(in);
|
||||
}
|
|
@ -20,7 +20,7 @@ package org.elasticsearch.cluster.metadata;
|
|||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.elasticsearch.ElasticsearchStatusException;
|
||||
import org.elasticsearch.OpenSearchStatusException;
|
||||
import org.elasticsearch.ResourceAlreadyExistsException;
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
|
@ -152,10 +152,10 @@ public class MetadataCreateDataStreamService {
|
|||
try {
|
||||
currentState = metadataCreateIndexService.applyCreateIndexRequest(currentState, createIndexRequest, false);
|
||||
} catch (ResourceAlreadyExistsException e) {
|
||||
// Rethrow as ElasticsearchStatusException, so that bulk transport action doesn't ignore it during
|
||||
// Rethrow as OpenSearchStatusException, so that bulk transport action doesn't ignore it during
|
||||
// auto index/data stream creation.
|
||||
// (otherwise bulk execution fails later, because data stream will also not have been created)
|
||||
throw new ElasticsearchStatusException("data stream could not be created because backing index [{}] already exists",
|
||||
throw new OpenSearchStatusException("data stream could not be created because backing index [{}] already exists",
|
||||
RestStatus.BAD_REQUEST, e, firstBackingIndexName);
|
||||
}
|
||||
IndexMetadata firstBackingIndex = currentState.metadata().index(firstBackingIndexName);
|
||||
|
|
|
@ -24,7 +24,7 @@ import org.apache.logging.log4j.Logger;
|
|||
import org.apache.logging.log4j.message.ParameterizedMessage;
|
||||
import org.apache.logging.log4j.util.Supplier;
|
||||
import org.elasticsearch.OpenSearchException;
|
||||
import org.elasticsearch.ElasticsearchStatusException;
|
||||
import org.elasticsearch.OpenSearchStatusException;
|
||||
import org.elasticsearch.ExceptionsHelper;
|
||||
import org.elasticsearch.common.bytes.BytesArray;
|
||||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
|
@ -158,7 +158,7 @@ public class BytesRestResponse extends RestResponse {
|
|||
.endObject());
|
||||
}
|
||||
|
||||
public static ElasticsearchStatusException errorFromXContent(XContentParser parser) throws IOException {
|
||||
public static OpenSearchStatusException errorFromXContent(XContentParser parser) throws IOException {
|
||||
XContentParser.Token token = parser.nextToken();
|
||||
ensureExpectedToken(XContentParser.Token.START_OBJECT, token, parser);
|
||||
|
||||
|
@ -184,7 +184,7 @@ public class BytesRestResponse extends RestResponse {
|
|||
throw new IllegalStateException("Failed to parse elasticsearch status exception: no exception was found");
|
||||
}
|
||||
|
||||
ElasticsearchStatusException result = new ElasticsearchStatusException(exception.getMessage(), status, exception.getCause());
|
||||
OpenSearchStatusException result = new OpenSearchStatusException(exception.getMessage(), status, exception.getCause());
|
||||
for (String header : exception.getHeaderKeys()) {
|
||||
result.addHeader(header, exception.getHeader(header));
|
||||
}
|
||||
|
|
|
@ -816,7 +816,7 @@ public class ExceptionSerializationTests extends ESTestCase {
|
|||
ids.put(142, ShardStateAction.NoLongerPrimaryShardException.class);
|
||||
ids.put(143, org.elasticsearch.script.ScriptException.class);
|
||||
ids.put(144, org.elasticsearch.cluster.NotMasterException.class);
|
||||
ids.put(145, org.elasticsearch.ElasticsearchStatusException.class);
|
||||
ids.put(145, OpenSearchStatusException.class);
|
||||
ids.put(146, org.elasticsearch.tasks.TaskCancelledException.class);
|
||||
ids.put(147, org.elasticsearch.env.ShardLockObtainFailedException.class);
|
||||
ids.put(148, null);
|
||||
|
@ -885,8 +885,8 @@ public class ExceptionSerializationTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testElasticsearchRemoteException() throws IOException {
|
||||
ElasticsearchStatusException ex = new ElasticsearchStatusException("something", RestStatus.TOO_MANY_REQUESTS);
|
||||
ElasticsearchStatusException e = serialize(ex);
|
||||
OpenSearchStatusException ex = new OpenSearchStatusException("something", RestStatus.TOO_MANY_REQUESTS);
|
||||
OpenSearchStatusException e = serialize(ex);
|
||||
assertEquals(ex.status(), e.status());
|
||||
assertEquals(RestStatus.TOO_MANY_REQUESTS, e.status());
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
package org.elasticsearch.action.bulk;
|
||||
|
||||
import org.elasticsearch.OpenSearchException;
|
||||
import org.elasticsearch.ElasticsearchStatusException;
|
||||
import org.elasticsearch.OpenSearchStatusException;
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.DocWriteRequest;
|
||||
|
@ -191,7 +191,7 @@ public class TransportShardBulkActionTests extends IndexShardTestCase {
|
|||
// Preemptively abort one of the bulk items, but allow the others to proceed
|
||||
BulkItemRequest rejectItem = randomFrom(items);
|
||||
RestStatus rejectionStatus = randomFrom(RestStatus.BAD_REQUEST, RestStatus.CONFLICT, RestStatus.FORBIDDEN, RestStatus.LOCKED);
|
||||
final ElasticsearchStatusException rejectionCause = new ElasticsearchStatusException("testing rejection", rejectionStatus);
|
||||
final OpenSearchStatusException rejectionCause = new OpenSearchStatusException("testing rejection", rejectionStatus);
|
||||
rejectItem.abort("index", rejectionCause);
|
||||
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
|
|
|
@ -19,8 +19,8 @@
|
|||
|
||||
package org.elasticsearch.rest;
|
||||
|
||||
import org.elasticsearch.ElasticsearchStatusException;
|
||||
import org.elasticsearch.ExceptionsHelper;
|
||||
import org.elasticsearch.OpenSearchStatusException;
|
||||
import org.elasticsearch.OpenSearchException;
|
||||
import org.elasticsearch.ResourceAlreadyExistsException;
|
||||
import org.elasticsearch.ResourceNotFoundException;
|
||||
|
@ -259,13 +259,13 @@ public class BytesRestResponseTests extends ESTestCase {
|
|||
break;
|
||||
case 5:
|
||||
status = randomFrom(RestStatus.values());
|
||||
original = new ElasticsearchStatusException("ElasticsearchStatusException with random status", status);
|
||||
original = new OpenSearchStatusException("OpenSearchStatusException with random status", status);
|
||||
if (detailed) {
|
||||
addHeadersOrMetadata = randomBoolean();
|
||||
type = "status_exception";
|
||||
reason = "ElasticsearchStatusException with random status";
|
||||
reason = "OpenSearchStatusException with random status";
|
||||
} else {
|
||||
reason = "ElasticsearchStatusException[ElasticsearchStatusException with random status]";
|
||||
reason = "OpenSearchStatusException[OpenSearchStatusException with random status]";
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -273,7 +273,7 @@ public class BytesRestResponseTests extends ESTestCase {
|
|||
}
|
||||
|
||||
String message = "Elasticsearch exception [type=" + type + ", reason=" + reason + "]";
|
||||
ElasticsearchStatusException expected = new ElasticsearchStatusException(message, status, cause);
|
||||
OpenSearchStatusException expected = new OpenSearchStatusException(message, status, cause);
|
||||
|
||||
if (addHeadersOrMetadata) {
|
||||
OpenSearchException originalException = ((OpenSearchException) original);
|
||||
|
|
Loading…
Reference in New Issue