diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/CreateIndexRequest.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/CreateIndexRequest.java index 1b31bd270b727..88804787fde44 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/CreateIndexRequest.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/CreateIndexRequest.java @@ -20,7 +20,7 @@ package org.elasticsearch.client.indices; import org.elasticsearch.OpenSearchGenerationException; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.action.admin.indices.alias.Alias; import org.elasticsearch.action.support.ActiveShardCount; import org.elasticsearch.client.TimedRequest; @@ -239,7 +239,7 @@ public CreateIndexRequest aliases(BytesReference source, XContentType contentTyp } return this; } catch(IOException e) { - throw new ElasticsearchParseException("Failed to parse aliases", e); + throw new OpenSearchParseException("Failed to parse aliases", e); } } diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/PutIndexTemplateRequest.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/PutIndexTemplateRequest.java index 67b04866d256a..133e21433ad86 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/PutIndexTemplateRequest.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/PutIndexTemplateRequest.java @@ -19,7 +19,7 @@ package org.elasticsearch.client.indices; import org.elasticsearch.OpenSearchGenerationException; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.IndicesRequest; import org.elasticsearch.action.admin.indices.alias.Alias; @@ -320,7 +320,7 @@ public PutIndexTemplateRequest source(Map templateSource) { } else if (name.equals("aliases")) { aliases((Map) entry.getValue()); } else { - throw new ElasticsearchParseException("unknown key [{}] in the template ", name); + throw new OpenSearchParseException("unknown key [{}] in the template ", name); } } return this; @@ -400,7 +400,7 @@ public PutIndexTemplateRequest aliases(BytesReference source) { } return this; } catch(IOException e) { - throw new ElasticsearchParseException("Failed to parse aliases", e); + throw new OpenSearchParseException("Failed to parse aliases", e); } } diff --git a/libs/core/src/test/java/org/elasticsearch/common/unit/TimeValueTests.java b/libs/core/src/test/java/org/elasticsearch/common/unit/TimeValueTests.java index 5ee32099115d9..ff58b88a704f8 100644 --- a/libs/core/src/test/java/org/elasticsearch/common/unit/TimeValueTests.java +++ b/libs/core/src/test/java/org/elasticsearch/common/unit/TimeValueTests.java @@ -172,7 +172,7 @@ private String randomTimeUnit() { public void testFailOnUnknownUnits() { try { TimeValue.parseTimeValue("23tw", null, "test"); - fail("Expected ElasticsearchParseException"); + fail("Expected OpenSearchParseException"); } catch (IllegalArgumentException e) { assertThat(e.getMessage(), containsString("failed to parse")); } @@ -181,7 +181,7 @@ public void testFailOnUnknownUnits() { public void testFailOnMissingUnits() { try { TimeValue.parseTimeValue("42", null, "test"); - fail("Expected ElasticsearchParseException"); + fail("Expected OpenSearchParseException"); } catch (IllegalArgumentException e) { assertThat(e.getMessage(), containsString("failed to parse")); } @@ -190,7 +190,7 @@ public void testFailOnMissingUnits() { public void testNoDotsAllowed() { try { TimeValue.parseTimeValue("42ms.", null, "test"); - fail("Expected ElasticsearchParseException"); + fail("Expected OpenSearchParseException"); } catch (IllegalArgumentException e) { assertThat(e.getMessage(), containsString("failed to parse")); } diff --git a/modules/ingest-common/src/internalClusterTest/java/org/elasticsearch/ingest/common/IngestRestartIT.java b/modules/ingest-common/src/internalClusterTest/java/org/elasticsearch/ingest/common/IngestRestartIT.java index b020a55db3182..33a4c5f28e255 100644 --- a/modules/ingest-common/src/internalClusterTest/java/org/elasticsearch/ingest/common/IngestRestartIT.java +++ b/modules/ingest-common/src/internalClusterTest/java/org/elasticsearch/ingest/common/IngestRestartIT.java @@ -164,7 +164,7 @@ public Settings onNodeStopped(String nodeName) { .get()); assertThat(exception.getMessage(), equalTo("pipeline with id [" + pipelineIdWithScript + "] could not be loaded, caused by " + - "[ElasticsearchParseException[Error updating pipeline with id [" + pipelineIdWithScript + "]]; " + + "[OpenSearchParseException[Error updating pipeline with id [" + pipelineIdWithScript + "]]; " + "nested: OpenSearchException[java.lang.IllegalArgumentException: cannot execute [inline] scripts]; " + "nested: IllegalArgumentException[cannot execute [inline] scripts];; " + "OpenSearchException[java.lang.IllegalArgumentException: cannot execute [inline] scripts]; " + diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/AbstractStringProcessorFactoryTestCase.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/AbstractStringProcessorFactoryTestCase.java index 1e5b2ae2431eb..781609203c2ae 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/AbstractStringProcessorFactoryTestCase.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/AbstractStringProcessorFactoryTestCase.java @@ -19,7 +19,7 @@ package org.elasticsearch.ingest.common; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.ingest.RandomDocumentPicks; import org.elasticsearch.test.ESTestCase; @@ -96,7 +96,7 @@ public void testCreateMissingField() throws Exception { try { factory.create(null, null, null, config); fail("factory create should have failed"); - } catch(ElasticsearchParseException e) { + } catch(OpenSearchParseException e) { assertThat(e.getMessage(), equalTo("[field] required property is missing")); } } diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/AppendProcessorFactoryTests.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/AppendProcessorFactoryTests.java index 26e39b08235ec..67f5a76a56308 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/AppendProcessorFactoryTests.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/AppendProcessorFactoryTests.java @@ -20,7 +20,7 @@ package org.elasticsearch.ingest.common; import org.elasticsearch.OpenSearchException; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.ingest.TestTemplateService; import org.elasticsearch.test.ESTestCase; import org.junit.Before; @@ -64,7 +64,7 @@ public void testCreateNoFieldPresent() throws Exception { try { factory.create(null, null, null, config); fail("factory create should have failed"); - } catch(ElasticsearchParseException e) { + } catch(OpenSearchParseException e) { assertThat(e.getMessage(), equalTo("[field] required property is missing")); } } @@ -75,7 +75,7 @@ public void testCreateNoValuePresent() throws Exception { try { factory.create(null, null, null, config); fail("factory create should have failed"); - } catch(ElasticsearchParseException e) { + } catch(OpenSearchParseException e) { assertThat(e.getMessage(), equalTo("[value] required property is missing")); } } @@ -87,7 +87,7 @@ public void testCreateNullValue() throws Exception { try { factory.create(null, null, null, config); fail("factory create should have failed"); - } catch(ElasticsearchParseException e) { + } catch(OpenSearchParseException e) { assertThat(e.getMessage(), equalTo("[value] required property is missing")); } } diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/ConvertProcessorFactoryTests.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/ConvertProcessorFactoryTests.java index 862349daaff1d..9115a1d34b1af 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/ConvertProcessorFactoryTests.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/ConvertProcessorFactoryTests.java @@ -19,7 +19,7 @@ package org.elasticsearch.ingest.common; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.test.ESTestCase; import org.hamcrest.Matchers; @@ -56,7 +56,7 @@ public void testCreateUnsupportedType() throws Exception { try { factory.create(null, null, null, config); fail("factory create should have failed"); - } catch (ElasticsearchParseException e) { + } catch (OpenSearchParseException e) { assertThat(e.getMessage(), Matchers.equalTo("[type] type [" + type + "] not supported, cannot convert field.")); assertThat(e.getMetadata("es.processor_type").get(0), equalTo(ConvertProcessor.TYPE)); assertThat(e.getMetadata("es.property_name").get(0), equalTo("type")); @@ -72,7 +72,7 @@ public void testCreateNoFieldPresent() throws Exception { try { factory.create(null, null, null, config); fail("factory create should have failed"); - } catch (ElasticsearchParseException e) { + } catch (OpenSearchParseException e) { assertThat(e.getMessage(), Matchers.equalTo("[field] required property is missing")); } } @@ -84,7 +84,7 @@ public void testCreateNoTypePresent() throws Exception { try { factory.create(null, null, null, config); fail("factory create should have failed"); - } catch (ElasticsearchParseException e) { + } catch (OpenSearchParseException e) { assertThat(e.getMessage(), Matchers.equalTo("[type] required property is missing")); } } diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/DateIndexNameFactoryTests.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/DateIndexNameFactoryTests.java index cd3e597f21a7f..04a70dc2e29ae 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/DateIndexNameFactoryTests.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/DateIndexNameFactoryTests.java @@ -19,7 +19,7 @@ package org.elasticsearch.ingest.common; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.ingest.TestTemplateService; import org.elasticsearch.test.ESTestCase; import org.hamcrest.Matchers; @@ -89,12 +89,12 @@ public void testRequiredFields() throws Exception { DateIndexNameProcessor.Factory factory = new DateIndexNameProcessor.Factory(TestTemplateService.instance()); Map config = new HashMap<>(); config.put("date_rounding", "y"); - ElasticsearchParseException e = expectThrows(ElasticsearchParseException.class, () -> factory.create(null, null, null, config)); + OpenSearchParseException e = expectThrows(OpenSearchParseException.class, () -> factory.create(null, null, null, config)); assertThat(e.getMessage(), Matchers.equalTo("[field] required property is missing")); config.clear(); config.put("field", "_field"); - e = expectThrows(ElasticsearchParseException.class, () -> factory.create(null, null, null, config)); + e = expectThrows(OpenSearchParseException.class, () -> factory.create(null, null, null, config)); assertThat(e.getMessage(), Matchers.equalTo("[date_rounding] required property is missing")); } } diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/DateProcessorFactoryTests.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/DateProcessorFactoryTests.java index fae5b219554ce..7eab4150e3df4 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/DateProcessorFactoryTests.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/DateProcessorFactoryTests.java @@ -19,7 +19,7 @@ package org.elasticsearch.ingest.common; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.ingest.TestTemplateService; import org.elasticsearch.test.ESTestCase; import org.junit.Before; @@ -67,7 +67,7 @@ public void testMatchFieldIsMandatory() throws Exception { try { factory.create(null, null, null, config); fail("processor creation should have failed"); - } catch(ElasticsearchParseException e) { + } catch(OpenSearchParseException e) { assertThat(e.getMessage(), containsString("[field] required property is missing")); } } @@ -82,7 +82,7 @@ public void testMatchFormatsIsMandatory() throws Exception { try { factory.create(null, null, null, config); fail("processor creation should have failed"); - } catch(ElasticsearchParseException e) { + } catch(OpenSearchParseException e) { assertThat(e.getMessage(), containsString("[formats] required property is missing")); } } @@ -130,7 +130,7 @@ public void testParseMatchFormatsFailure() throws Exception { try { factory.create(null, null, null, config); fail("processor creation should have failed"); - } catch(ElasticsearchParseException e) { + } catch(OpenSearchParseException e) { assertThat(e.getMessage(), containsString("[formats] property isn't a list, but of type [java.lang.String]")); } } diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/DissectProcessorFactoryTests.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/DissectProcessorFactoryTests.java index f8377acd26839..519b58784b4a7 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/DissectProcessorFactoryTests.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/DissectProcessorFactoryTests.java @@ -19,7 +19,7 @@ package org.elasticsearch.ingest.common; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.dissect.DissectException; import org.elasticsearch.ingest.RandomDocumentPicks; import org.elasticsearch.test.ESTestCase; @@ -60,7 +60,7 @@ public void testCreateMissingField() { DissectProcessor.Factory factory = new DissectProcessor.Factory(); Map config = new HashMap<>(); config.put("pattern", "%{a},%{b},%{c}"); - Exception e = expectThrows(ElasticsearchParseException.class, () -> factory.create(null, "_tag", null, config)); + Exception e = expectThrows(OpenSearchParseException.class, () -> factory.create(null, "_tag", null, config)); assertThat(e.getMessage(), Matchers.equalTo("[field] required property is missing")); } @@ -68,7 +68,7 @@ public void testCreateMissingPattern() { DissectProcessor.Factory factory = new DissectProcessor.Factory(); Map config = new HashMap<>(); config.put("field", randomAlphaOfLength(10)); - Exception e = expectThrows(ElasticsearchParseException.class, () -> factory.create(null, "_tag", null, config)); + Exception e = expectThrows(OpenSearchParseException.class, () -> factory.create(null, "_tag", null, config)); assertThat(e.getMessage(), Matchers.equalTo("[pattern] required property is missing")); } diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/DotExpanderProcessorFactoryTests.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/DotExpanderProcessorFactoryTests.java index dce33e84c7ddb..cd00408f784bd 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/DotExpanderProcessorFactoryTests.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/DotExpanderProcessorFactoryTests.java @@ -19,7 +19,7 @@ package org.elasticsearch.ingest.common; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.test.ESTestCase; import java.util.HashMap; @@ -66,7 +66,7 @@ public void testCreate_fieldMissing() throws Exception { Map config = new HashMap<>(); config.put("path", "_path"); - Exception e = expectThrows(ElasticsearchParseException.class, () -> factory.create(null, "_tag", null, config)); + Exception e = expectThrows(OpenSearchParseException.class, () -> factory.create(null, "_tag", null, config)); assertThat(e.getMessage(), equalTo("[field] required property is missing")); } @@ -76,7 +76,7 @@ public void testCreate_invalidFields() throws Exception { for (String field : fields) { Map config = new HashMap<>(); config.put("field", field); - Exception e = expectThrows(ElasticsearchParseException.class, () -> factory.create(null, "_tag", null, config)); + Exception e = expectThrows(OpenSearchParseException.class, () -> factory.create(null, "_tag", null, config)); assertThat(e.getMessage(), equalTo("[field] field does not contain a dot")); } @@ -84,7 +84,7 @@ public void testCreate_invalidFields() throws Exception { for (String field : fields) { Map config = new HashMap<>(); config.put("field", field); - Exception e = expectThrows(ElasticsearchParseException.class, () -> factory.create(null, "_tag", null, config)); + Exception e = expectThrows(OpenSearchParseException.class, () -> factory.create(null, "_tag", null, config)); assertThat(e.getMessage(), equalTo("[field] Field can't start or end with a dot")); } @@ -92,7 +92,7 @@ public void testCreate_invalidFields() throws Exception { for (String field : fields) { Map config = new HashMap<>(); config.put("field", field); - Exception e = expectThrows(ElasticsearchParseException.class, () -> factory.create(null, "_tag", null, config)); + Exception e = expectThrows(OpenSearchParseException.class, () -> factory.create(null, "_tag", null, config)); assertThat(e.getMessage(), equalTo("[field] No space between dots")); } } diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/FailProcessorFactoryTests.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/FailProcessorFactoryTests.java index 1678f6351d398..2b2810e6b2f88 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/FailProcessorFactoryTests.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/FailProcessorFactoryTests.java @@ -20,7 +20,7 @@ package org.elasticsearch.ingest.common; import org.elasticsearch.OpenSearchException; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.ingest.TestTemplateService; import org.elasticsearch.test.ESTestCase; import org.junit.Before; @@ -54,7 +54,7 @@ public void testCreateMissingMessageField() throws Exception { try { factory.create(null, null, null, config); fail("factory create should have failed"); - } catch(ElasticsearchParseException e) { + } catch(OpenSearchParseException e) { assertThat(e.getMessage(), equalTo("[message] required property is missing")); } } diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/ForEachProcessorFactoryTests.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/ForEachProcessorFactoryTests.java index ff43a2f81cb71..f80fe39f65ba9 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/ForEachProcessorFactoryTests.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/ForEachProcessorFactoryTests.java @@ -19,7 +19,7 @@ package org.elasticsearch.ingest.common; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.ingest.Processor; import org.elasticsearch.ingest.TestProcessor; import org.elasticsearch.script.ScriptService; @@ -85,7 +85,7 @@ public void testCreateWithTooManyProcessorTypes() throws Exception { processorTypes.put("_first", Collections.emptyMap()); processorTypes.put("_second", Collections.emptyMap()); config.put("processor", processorTypes); - Exception exception = expectThrows(ElasticsearchParseException.class, () -> forEachFactory.create(registry, null, null, config)); + Exception exception = expectThrows(OpenSearchParseException.class, () -> forEachFactory.create(registry, null, null, config)); assertThat(exception.getMessage(), equalTo("[processor] Must specify exactly one processor type")); } @@ -94,7 +94,7 @@ public void testCreateWithNonExistingProcessorType() throws Exception { Map config = new HashMap<>(); config.put("field", "_field"); config.put("processor", Collections.singletonMap("_name", Collections.emptyMap())); - Exception expectedException = expectThrows(ElasticsearchParseException.class, + Exception expectedException = expectThrows(OpenSearchParseException.class, () -> forEachFactory.create(Collections.emptyMap(), null, null, config)); assertThat(expectedException.getMessage(), equalTo("No processor type exists with name [_name]")); } diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/GrokProcessorFactoryTests.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/GrokProcessorFactoryTests.java index fcc51e10b84f7..fdbb0ecdeb2fa 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/GrokProcessorFactoryTests.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/GrokProcessorFactoryTests.java @@ -19,7 +19,7 @@ package org.elasticsearch.ingest.common; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.grok.MatcherWatchdog; import org.elasticsearch.test.ESTestCase; @@ -66,7 +66,7 @@ public void testBuildMissingField() throws Exception { GrokProcessor.Factory factory = new GrokProcessor.Factory(Collections.emptyMap(), MatcherWatchdog.noop()); Map config = new HashMap<>(); config.put("patterns", Collections.singletonList("(?\\w+)")); - ElasticsearchParseException e = expectThrows(ElasticsearchParseException.class, () -> factory.create(null, null, null, config)); + OpenSearchParseException e = expectThrows(OpenSearchParseException.class, () -> factory.create(null, null, null, config)); assertThat(e.getMessage(), equalTo("[field] required property is missing")); } @@ -74,7 +74,7 @@ public void testBuildMissingPatterns() throws Exception { GrokProcessor.Factory factory = new GrokProcessor.Factory(Collections.emptyMap(), MatcherWatchdog.noop()); Map config = new HashMap<>(); config.put("field", "foo"); - ElasticsearchParseException e = expectThrows(ElasticsearchParseException.class, () -> factory.create(null, null, null, config)); + OpenSearchParseException e = expectThrows(OpenSearchParseException.class, () -> factory.create(null, null, null, config)); assertThat(e.getMessage(), equalTo("[patterns] required property is missing")); } @@ -83,7 +83,7 @@ public void testBuildEmptyPatternsList() throws Exception { Map config = new HashMap<>(); config.put("field", "foo"); config.put("patterns", Collections.emptyList()); - ElasticsearchParseException e = expectThrows(ElasticsearchParseException.class, () -> factory.create(null, null, null, config)); + OpenSearchParseException e = expectThrows(OpenSearchParseException.class, () -> factory.create(null, null, null, config)); assertThat(e.getMessage(), equalTo("[patterns] List of patterns must not be empty")); } @@ -105,7 +105,7 @@ public void testCreateWithInvalidPattern() throws Exception { Map config = new HashMap<>(); config.put("field", "_field"); config.put("patterns", Collections.singletonList("[")); - ElasticsearchParseException e = expectThrows(ElasticsearchParseException.class, () -> factory.create(null, null, null, config)); + OpenSearchParseException e = expectThrows(OpenSearchParseException.class, () -> factory.create(null, null, null, config)); assertThat(e.getMessage(), equalTo("[patterns] Invalid regex pattern found in: [[]. premature end of char-class")); } @@ -115,7 +115,7 @@ public void testCreateWithInvalidPatternDefinition() throws Exception { config.put("field", "_field"); config.put("patterns", Collections.singletonList("%{MY_PATTERN:name}!")); config.put("pattern_definitions", Collections.singletonMap("MY_PATTERN", "[")); - ElasticsearchParseException e = expectThrows(ElasticsearchParseException.class, () -> factory.create(null, null, null, config)); + OpenSearchParseException e = expectThrows(OpenSearchParseException.class, () -> factory.create(null, null, null, config)); assertThat(e.getMessage(), equalTo("[patterns] Invalid regex pattern found in: [%{MY_PATTERN:name}!]. premature end of char-class")); } diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/GsubProcessorFactoryTests.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/GsubProcessorFactoryTests.java index d5c9a5a9d011d..974b2f7cd2ed7 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/GsubProcessorFactoryTests.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/GsubProcessorFactoryTests.java @@ -19,7 +19,7 @@ package org.elasticsearch.ingest.common; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import java.util.HashMap; import java.util.Map; @@ -56,7 +56,7 @@ public void testCreateNoPatternPresent() throws Exception { try { factory.create(null, null, null, config); fail("factory create should have failed"); - } catch(ElasticsearchParseException e) { + } catch(OpenSearchParseException e) { assertThat(e.getMessage(), equalTo("[pattern] required property is missing")); } } @@ -69,7 +69,7 @@ public void testCreateNoReplacementPresent() throws Exception { try { factory.create(null, null, null, config); fail("factory create should have failed"); - } catch(ElasticsearchParseException e) { + } catch(OpenSearchParseException e) { assertThat(e.getMessage(), equalTo("[replacement] required property is missing")); } } @@ -83,7 +83,7 @@ public void testCreateInvalidPattern() throws Exception { try { factory.create(null, null, null, config); fail("factory create should have failed"); - } catch(ElasticsearchParseException e) { + } catch(OpenSearchParseException e) { assertThat(e.getMessage(), containsString("[pattern] Invalid regex pattern. Unclosed character class")); } } diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/JoinProcessorFactoryTests.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/JoinProcessorFactoryTests.java index 8da58c8d523ea..0fb13ede3e85e 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/JoinProcessorFactoryTests.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/JoinProcessorFactoryTests.java @@ -19,7 +19,7 @@ package org.elasticsearch.ingest.common; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.test.ESTestCase; import java.util.HashMap; @@ -49,7 +49,7 @@ public void testCreateNoFieldPresent() throws Exception { try { factory.create(null, null, null, config); fail("factory create should have failed"); - } catch (ElasticsearchParseException e) { + } catch (OpenSearchParseException e) { assertThat(e.getMessage(), equalTo("[field] required property is missing")); } } @@ -61,7 +61,7 @@ public void testCreateNoSeparatorPresent() throws Exception { try { factory.create(null, null, null, config); fail("factory create should have failed"); - } catch (ElasticsearchParseException e) { + } catch (OpenSearchParseException e) { assertThat(e.getMessage(), equalTo("[separator] required property is missing")); } } diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/JsonProcessorFactoryTests.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/JsonProcessorFactoryTests.java index 8fe9a1a65b908..39f66eda17d68 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/JsonProcessorFactoryTests.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/JsonProcessorFactoryTests.java @@ -20,7 +20,7 @@ package org.elasticsearch.ingest.common; import org.elasticsearch.OpenSearchException; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.test.ESTestCase; import java.util.HashMap; @@ -72,7 +72,7 @@ public void testCreateWithDefaultTarget() throws Exception { public void testCreateWithMissingField() throws Exception { Map config = new HashMap<>(); String processorTag = randomAlphaOfLength(10); - OpenSearchException exception = expectThrows(ElasticsearchParseException.class, + OpenSearchException exception = expectThrows(OpenSearchParseException.class, () -> FACTORY.create(null, processorTag, null, config)); assertThat(exception.getMessage(), equalTo("[field] required property is missing")); } @@ -84,7 +84,7 @@ public void testCreateWithBothTargetFieldAndAddToRoot() throws Exception { config.put("field", randomField); config.put("target_field", randomTargetField); config.put("add_to_root", true); - OpenSearchException exception = expectThrows(ElasticsearchParseException.class, + OpenSearchException exception = expectThrows(OpenSearchParseException.class, () -> FACTORY.create(null, randomAlphaOfLength(10), null, config)); assertThat(exception.getMessage(), equalTo("[target_field] Cannot set a target field while also setting `add_to_root` to true")); } diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/KeyValueProcessorFactoryTests.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/KeyValueProcessorFactoryTests.java index d460621896826..8519795c97128 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/KeyValueProcessorFactoryTests.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/KeyValueProcessorFactoryTests.java @@ -20,7 +20,7 @@ package org.elasticsearch.ingest.common; import org.elasticsearch.OpenSearchException; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.common.util.set.Sets; import org.elasticsearch.test.ESTestCase; @@ -78,7 +78,7 @@ public void testCreateWithMissingField() { KeyValueProcessor.Factory factory = new KeyValueProcessor.Factory(); Map config = new HashMap<>(); String processorTag = randomAlphaOfLength(10); - OpenSearchException exception = expectThrows(ElasticsearchParseException.class, + OpenSearchException exception = expectThrows(OpenSearchParseException.class, () -> factory.create(null, processorTag, null, config)); assertThat(exception.getMessage(), equalTo("[field] required property is missing")); } @@ -88,7 +88,7 @@ public void testCreateWithMissingFieldSplit() { Map config = new HashMap<>(); config.put("field", "field1"); String processorTag = randomAlphaOfLength(10); - OpenSearchException exception = expectThrows(ElasticsearchParseException.class, + OpenSearchException exception = expectThrows(OpenSearchParseException.class, () -> factory.create(null, processorTag, null, config)); assertThat(exception.getMessage(), equalTo("[field_split] required property is missing")); } @@ -99,7 +99,7 @@ public void testCreateWithMissingValueSplit() { config.put("field", "field1"); config.put("field_split", "&"); String processorTag = randomAlphaOfLength(10); - OpenSearchException exception = expectThrows(ElasticsearchParseException.class, + OpenSearchException exception = expectThrows(OpenSearchParseException.class, () -> factory.create(null, processorTag, null, config)); assertThat(exception.getMessage(), equalTo("[value_split] required property is missing")); } diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/RemoveProcessorFactoryTests.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/RemoveProcessorFactoryTests.java index 4d693b3e88ba1..f9d29cfc7b2dd 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/RemoveProcessorFactoryTests.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/RemoveProcessorFactoryTests.java @@ -20,7 +20,7 @@ package org.elasticsearch.ingest.common; import org.elasticsearch.OpenSearchException; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.ingest.TestTemplateService; import org.elasticsearch.test.ESTestCase; import org.junit.Before; @@ -67,7 +67,7 @@ public void testCreateMissingField() throws Exception { try { factory.create(null, null, null, config); fail("factory create should have failed"); - } catch(ElasticsearchParseException e) { + } catch(OpenSearchParseException e) { assertThat(e.getMessage(), equalTo("[field] required property is missing")); } } diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/RenameProcessorFactoryTests.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/RenameProcessorFactoryTests.java index 15e07b4deb9b1..aa6b161526ff7 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/RenameProcessorFactoryTests.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/RenameProcessorFactoryTests.java @@ -19,7 +19,7 @@ package org.elasticsearch.ingest.common; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.ingest.TestTemplateService; import org.elasticsearch.test.ESTestCase; import org.junit.Before; @@ -70,7 +70,7 @@ public void testCreateNoFieldPresent() throws Exception { try { factory.create(null, null, null, config); fail("factory create should have failed"); - } catch(ElasticsearchParseException e) { + } catch(OpenSearchParseException e) { assertThat(e.getMessage(), equalTo("[field] required property is missing")); } } @@ -81,7 +81,7 @@ public void testCreateNoToPresent() throws Exception { try { factory.create(null, null, null, config); fail("factory create should have failed"); - } catch(ElasticsearchParseException e) { + } catch(OpenSearchParseException e) { assertThat(e.getMessage(), equalTo("[target_field] required property is missing")); } } diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/SetProcessorFactoryTests.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/SetProcessorFactoryTests.java index ad9083cd04392..6cf8e210f97fe 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/SetProcessorFactoryTests.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/SetProcessorFactoryTests.java @@ -20,7 +20,7 @@ package org.elasticsearch.ingest.common; import org.elasticsearch.OpenSearchException; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.ingest.TestTemplateService; import org.elasticsearch.test.ESTestCase; import org.junit.Before; @@ -72,7 +72,7 @@ public void testCreateNoFieldPresent() throws Exception { try { factory.create(null, null, null, config); fail("factory create should have failed"); - } catch(ElasticsearchParseException e) { + } catch(OpenSearchParseException e) { assertThat(e.getMessage(), equalTo("[field] required property is missing")); } } @@ -83,7 +83,7 @@ public void testCreateNoValuePresent() throws Exception { try { factory.create(null, null, null, config); fail("factory create should have failed"); - } catch(ElasticsearchParseException e) { + } catch(OpenSearchParseException e) { assertThat(e.getMessage(), equalTo("[value] required property is missing")); } } @@ -95,7 +95,7 @@ public void testCreateNullValue() throws Exception { try { factory.create(null, null, null, config); fail("factory create should have failed"); - } catch(ElasticsearchParseException e) { + } catch(OpenSearchParseException e) { assertThat(e.getMessage(), equalTo("[value] required property is missing")); } } diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/SortProcessorFactoryTests.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/SortProcessorFactoryTests.java index 2e1665fa71124..2e5c2870d914b 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/SortProcessorFactoryTests.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/SortProcessorFactoryTests.java @@ -19,7 +19,7 @@ package org.elasticsearch.ingest.common; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.ingest.RandomDocumentPicks; import org.elasticsearch.test.ESTestCase; @@ -90,7 +90,7 @@ public void testCreateWithInvalidOrder() throws Exception { try { factory.create(null, processorTag, null, config); fail("factory create should have failed"); - } catch (ElasticsearchParseException e) { + } catch (OpenSearchParseException e) { assertThat(e.getMessage(), equalTo("[order] Sort direction [invalid] not recognized. Valid values are: [asc, desc]")); } } @@ -101,7 +101,7 @@ public void testCreateMissingField() throws Exception { try { factory.create(null, null, null, config); fail("factory create should have failed"); - } catch(ElasticsearchParseException e) { + } catch(OpenSearchParseException e) { assertThat(e.getMessage(), equalTo("[field] required property is missing")); } } diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/SplitProcessorFactoryTests.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/SplitProcessorFactoryTests.java index b70a577e51408..c0cf4b8cb1ac5 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/SplitProcessorFactoryTests.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/SplitProcessorFactoryTests.java @@ -19,7 +19,7 @@ package org.elasticsearch.ingest.common; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.test.ESTestCase; import java.util.HashMap; @@ -50,7 +50,7 @@ public void testCreateNoFieldPresent() throws Exception { try { factory.create(null, null, null, config); fail("factory create should have failed"); - } catch(ElasticsearchParseException e) { + } catch(OpenSearchParseException e) { assertThat(e.getMessage(), equalTo("[field] required property is missing")); } } @@ -62,7 +62,7 @@ public void testCreateNoSeparatorPresent() throws Exception { try { factory.create(null, null, null, config); fail("factory create should have failed"); - } catch(ElasticsearchParseException e) { + } catch(OpenSearchParseException e) { assertThat(e.getMessage(), equalTo("[separator] required property is missing")); } } diff --git a/modules/ingest-geoip/src/main/java/org/elasticsearch/ingest/geoip/GeoIpProcessor.java b/modules/ingest-geoip/src/main/java/org/elasticsearch/ingest/geoip/GeoIpProcessor.java index 0c9080f58affc..5b7865eba4217 100644 --- a/modules/ingest-geoip/src/main/java/org/elasticsearch/ingest/geoip/GeoIpProcessor.java +++ b/modules/ingest-geoip/src/main/java/org/elasticsearch/ingest/geoip/GeoIpProcessor.java @@ -29,7 +29,7 @@ import com.maxmind.geoip2.record.Country; import com.maxmind.geoip2.record.Location; import com.maxmind.geoip2.record.Subdivision; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.SpecialPermission; import org.elasticsearch.common.network.InetAddresses; import org.elasticsearch.common.network.NetworkAddress; @@ -173,7 +173,7 @@ private Map getGeoData(String ip) throws IOException { geoData = Collections.emptyMap(); } } else { - throw new ElasticsearchParseException("Unsupported database type [" + lazyLoader.getDatabaseType() + throw new OpenSearchParseException("Unsupported database type [" + lazyLoader.getDatabaseType() + "]", new IllegalStateException()); } return geoData; diff --git a/modules/ingest-geoip/src/test/java/org/elasticsearch/ingest/geoip/GeoIpProcessorFactoryTests.java b/modules/ingest-geoip/src/test/java/org/elasticsearch/ingest/geoip/GeoIpProcessorFactoryTests.java index 2b528df3b2e8c..00613b5582b6d 100644 --- a/modules/ingest-geoip/src/test/java/org/elasticsearch/ingest/geoip/GeoIpProcessorFactoryTests.java +++ b/modules/ingest-geoip/src/test/java/org/elasticsearch/ingest/geoip/GeoIpProcessorFactoryTests.java @@ -20,7 +20,7 @@ package org.elasticsearch.ingest.geoip; import com.carrotsearch.randomizedtesting.generators.RandomPicks; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.common.Randomness; import org.elasticsearch.index.VersionType; import org.elasticsearch.ingest.IngestDocument; @@ -173,7 +173,7 @@ public void testBuildWithCountryDbAndAsnFields() throws Exception { asnOnlyProperties.remove(GeoIpProcessor.Property.IP); String asnProperty = RandomPicks.randomFrom(Randomness.get(), asnOnlyProperties).toString(); config.put("properties", Collections.singletonList(asnProperty)); - Exception e = expectThrows(ElasticsearchParseException.class, () -> factory.create(null, null, null, config)); + Exception e = expectThrows(OpenSearchParseException.class, () -> factory.create(null, null, null, config)); assertThat(e.getMessage(), equalTo("[properties] illegal property value [" + asnProperty + "]. valid values are [IP, COUNTRY_ISO_CODE, COUNTRY_NAME, CONTINENT_NAME]")); } @@ -187,7 +187,7 @@ public void testBuildWithAsnDbAndCityFields() throws Exception { cityOnlyProperties.remove(GeoIpProcessor.Property.IP); String cityProperty = RandomPicks.randomFrom(Randomness.get(), cityOnlyProperties).toString(); config.put("properties", Collections.singletonList(cityProperty)); - Exception e = expectThrows(ElasticsearchParseException.class, () -> factory.create(null, null, null, config)); + Exception e = expectThrows(OpenSearchParseException.class, () -> factory.create(null, null, null, config)); assertThat(e.getMessage(), equalTo("[properties] illegal property value [" + cityProperty + "]. valid values are [IP, ASN, ORGANIZATION_NAME, NETWORK]")); } @@ -198,7 +198,7 @@ public void testBuildNonExistingDbFile() throws Exception { Map config = new HashMap<>(); config.put("field", "_field"); config.put("database_file", "does-not-exist.mmdb"); - Exception e = expectThrows(ElasticsearchParseException.class, () -> factory.create(null, null, null, config)); + Exception e = expectThrows(OpenSearchParseException.class, () -> factory.create(null, null, null, config)); assertThat(e.getMessage(), equalTo("[database_file] database file [does-not-exist.mmdb] doesn't exist")); } @@ -232,14 +232,14 @@ public void testBuildIllegalFieldOption() throws Exception { Map config1 = new HashMap<>(); config1.put("field", "_field"); config1.put("properties", Collections.singletonList("invalid")); - Exception e = expectThrows(ElasticsearchParseException.class, () -> factory.create(null, null, null, config1)); + Exception e = expectThrows(OpenSearchParseException.class, () -> factory.create(null, null, null, config1)); assertThat(e.getMessage(), equalTo("[properties] illegal property value [invalid]. valid values are [IP, COUNTRY_ISO_CODE, " + "COUNTRY_NAME, CONTINENT_NAME, REGION_ISO_CODE, REGION_NAME, CITY_NAME, TIMEZONE, LOCATION]")); Map config2 = new HashMap<>(); config2.put("field", "_field"); config2.put("properties", "invalid"); - e = expectThrows(ElasticsearchParseException.class, () -> factory.create(null, null, null, config2)); + e = expectThrows(OpenSearchParseException.class, () -> factory.create(null, null, null, config2)); assertThat(e.getMessage(), equalTo("[properties] property isn't a list, but of type [java.lang.String]")); } diff --git a/modules/ingest-user-agent/src/main/java/org/elasticsearch/ingest/useragent/UserAgentParser.java b/modules/ingest-user-agent/src/main/java/org/elasticsearch/ingest/useragent/UserAgentParser.java index f8aec041d742a..dd7fb342643b0 100644 --- a/modules/ingest-user-agent/src/main/java/org/elasticsearch/ingest/useragent/UserAgentParser.java +++ b/modules/ingest-user-agent/src/main/java/org/elasticsearch/ingest/useragent/UserAgentParser.java @@ -19,7 +19,7 @@ package org.elasticsearch.ingest.useragent; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.common.xcontent.LoggingDeprecationHandler; import org.elasticsearch.common.xcontent.NamedXContentRegistry; import org.elasticsearch.common.xcontent.XContentFactory; @@ -49,7 +49,7 @@ final class UserAgentParser { try { init(regexStream); } catch (IOException e) { - throw new ElasticsearchParseException("error parsing regular expression file", e); + throw new OpenSearchParseException("error parsing regular expression file", e); } } @@ -94,7 +94,7 @@ else if (token == XContentParser.Token.FIELD_NAME && yamlParser.currentName().eq } if (uaPatterns.isEmpty() && osPatterns.isEmpty() && devicePatterns.isEmpty()) { - throw new ElasticsearchParseException("not a valid regular expression file"); + throw new OpenSearchParseException("not a valid regular expression file"); } } @@ -112,19 +112,19 @@ private List> readParserConfigurations(XContentParser yamlPa XContentParser.Token token = yamlParser.nextToken(); if (token != XContentParser.Token.START_ARRAY) { - throw new ElasticsearchParseException("malformed regular expression file, should continue with 'array' after 'object'"); + throw new OpenSearchParseException("malformed regular expression file, should continue with 'array' after 'object'"); } token = yamlParser.nextToken(); if (token != XContentParser.Token.START_OBJECT) { - throw new ElasticsearchParseException("malformed regular expression file, expecting 'object'"); + throw new OpenSearchParseException("malformed regular expression file, expecting 'object'"); } while (token == XContentParser.Token.START_OBJECT) { token = yamlParser.nextToken(); if (token != XContentParser.Token.FIELD_NAME) { - throw new ElasticsearchParseException("malformed regular expression file, should continue with 'field_name' after 'array'"); + throw new OpenSearchParseException("malformed regular expression file, should continue with 'field_name' after 'array'"); } Map regexMap = new HashMap<>(); diff --git a/modules/ingest-user-agent/src/test/java/org/elasticsearch/ingest/useragent/UserAgentProcessorFactoryTests.java b/modules/ingest-user-agent/src/test/java/org/elasticsearch/ingest/useragent/UserAgentProcessorFactoryTests.java index 12de1b12d3b5e..ce574fcbde8d0 100644 --- a/modules/ingest-user-agent/src/test/java/org/elasticsearch/ingest/useragent/UserAgentProcessorFactoryTests.java +++ b/modules/ingest-user-agent/src/test/java/org/elasticsearch/ingest/useragent/UserAgentProcessorFactoryTests.java @@ -19,7 +19,7 @@ package org.elasticsearch.ingest.useragent; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.common.Strings; import org.elasticsearch.test.ESTestCase; import org.junit.BeforeClass; @@ -153,7 +153,7 @@ public void testBuildNonExistingRegexFile() throws Exception { config.put("field", "_field"); config.put("regex_file", "does-not-exist.yml"); - ElasticsearchParseException e = expectThrows(ElasticsearchParseException.class, () -> factory.create(null, null, null, config)); + OpenSearchParseException e = expectThrows(OpenSearchParseException.class, () -> factory.create(null, null, null, config)); assertThat(e.getMessage(), equalTo("[regex_file] regex file [does-not-exist.yml] doesn't exist (has to exist at node startup)")); } @@ -198,7 +198,7 @@ public void testInvalidProperty() throws Exception { config.put("field", "_field"); config.put("properties", Collections.singletonList("invalid")); - ElasticsearchParseException e = expectThrows(ElasticsearchParseException.class, () -> factory.create(null, null, null, config)); + OpenSearchParseException e = expectThrows(OpenSearchParseException.class, () -> factory.create(null, null, null, config)); assertThat(e.getMessage(), equalTo("[properties] illegal property value [invalid]. valid values are [NAME, MAJOR, MINOR, " + "PATCH, OS, OS_NAME, OS_MAJOR, OS_MINOR, DEVICE, BUILD, ORIGINAL, VERSION]")); } @@ -210,7 +210,7 @@ public void testInvalidPropertiesType() throws Exception { config.put("field", "_field"); config.put("properties", "invalid"); - ElasticsearchParseException e = expectThrows(ElasticsearchParseException.class, () -> factory.create(null, null, null, config)); + OpenSearchParseException e = expectThrows(OpenSearchParseException.class, () -> factory.create(null, null, null, config)); assertThat(e.getMessage(), equalTo("[properties] property isn't a list, but of type [java.lang.String]")); } } diff --git a/plugins/ingest-attachment/src/main/java/org/elasticsearch/ingest/attachment/AttachmentProcessor.java b/plugins/ingest-attachment/src/main/java/org/elasticsearch/ingest/attachment/AttachmentProcessor.java index e20b8e6025ba6..181517b233a18 100644 --- a/plugins/ingest-attachment/src/main/java/org/elasticsearch/ingest/attachment/AttachmentProcessor.java +++ b/plugins/ingest-attachment/src/main/java/org/elasticsearch/ingest/attachment/AttachmentProcessor.java @@ -23,7 +23,7 @@ import org.apache.tika.language.LanguageIdentifier; import org.apache.tika.metadata.Metadata; import org.apache.tika.metadata.TikaCoreProperties; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.common.Strings; import org.elasticsearch.ingest.AbstractProcessor; import org.elasticsearch.ingest.IngestDocument; @@ -103,7 +103,7 @@ public IngestDocument execute(IngestDocument ingestDocument) { // tika 1.17 throws an exception when the InputStream has 0 bytes. // previously, it did not mind. This is here to preserve that behavior. } catch (Exception e) { - throw new ElasticsearchParseException("Error parsing document in field [{}]", e, field); + throw new OpenSearchParseException("Error parsing document in field [{}]", e, field); } if (properties.contains(Property.CONTENT) && Strings.hasLength(parsedContent)) { diff --git a/plugins/ingest-attachment/src/test/java/org/elasticsearch/ingest/attachment/AttachmentProcessorFactoryTests.java b/plugins/ingest-attachment/src/test/java/org/elasticsearch/ingest/attachment/AttachmentProcessorFactoryTests.java index 8bb5ce3d35fc5..1c4c7ea7d43f5 100644 --- a/plugins/ingest-attachment/src/test/java/org/elasticsearch/ingest/attachment/AttachmentProcessorFactoryTests.java +++ b/plugins/ingest-attachment/src/test/java/org/elasticsearch/ingest/attachment/AttachmentProcessorFactoryTests.java @@ -19,7 +19,7 @@ package org.elasticsearch.ingest.attachment; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.test.ESTestCase; import java.util.ArrayList; @@ -102,7 +102,7 @@ public void testBuildIllegalFieldOption() throws Exception { try { factory.create(null, null, null, config); fail("exception expected"); - } catch (ElasticsearchParseException e) { + } catch (OpenSearchParseException e) { assertThat(e.getMessage(), containsString("[properties] illegal field option [invalid]")); // ensure allowed fields are mentioned for (AttachmentProcessor.Property property : AttachmentProcessor.Property.values()) { @@ -116,7 +116,7 @@ public void testBuildIllegalFieldOption() throws Exception { try { factory.create(null, null, null, config); fail("exception expected"); - } catch (ElasticsearchParseException e) { + } catch (OpenSearchParseException e) { assertThat(e.getMessage(), equalTo("[properties] property isn't a list, but of type [java.lang.String]")); } } diff --git a/plugins/ingest-attachment/src/test/java/org/elasticsearch/ingest/attachment/AttachmentProcessorTests.java b/plugins/ingest-attachment/src/test/java/org/elasticsearch/ingest/attachment/AttachmentProcessorTests.java index 38b03c1879e67..8d95757ab92cf 100644 --- a/plugins/ingest-attachment/src/test/java/org/elasticsearch/ingest/attachment/AttachmentProcessorTests.java +++ b/plugins/ingest-attachment/src/test/java/org/elasticsearch/ingest/attachment/AttachmentProcessorTests.java @@ -20,7 +20,7 @@ package org.elasticsearch.ingest.attachment; import org.apache.commons.io.IOUtils; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.ingest.IngestDocument; import org.elasticsearch.ingest.Processor; import org.elasticsearch.ingest.RandomDocumentPicks; @@ -173,7 +173,7 @@ public void testVisioIsExcluded() throws Exception { } public void testEncryptedPdf() throws Exception { - ElasticsearchParseException e = expectThrows(ElasticsearchParseException.class, () -> parseDocument("encrypted.pdf", processor)); + OpenSearchParseException e = expectThrows(OpenSearchParseException.class, () -> parseDocument("encrypted.pdf", processor)); assertThat(e.getDetailedMessage(), containsString("document is encrypted")); } diff --git a/plugins/mapper-annotated-text/src/main/java/org/elasticsearch/index/mapper/annotatedtext/AnnotatedTextFieldMapper.java b/plugins/mapper-annotated-text/src/main/java/org/elasticsearch/index/mapper/annotatedtext/AnnotatedTextFieldMapper.java index 6a49258b0d961..b3f6e543594f2 100644 --- a/plugins/mapper-annotated-text/src/main/java/org/elasticsearch/index/mapper/annotatedtext/AnnotatedTextFieldMapper.java +++ b/plugins/mapper-annotated-text/src/main/java/org/elasticsearch/index/mapper/annotatedtext/AnnotatedTextFieldMapper.java @@ -31,7 +31,7 @@ import org.apache.lucene.document.Field; import org.apache.lucene.document.FieldType; import org.apache.lucene.index.IndexOptions; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.index.analysis.AnalyzerScope; import org.elasticsearch.index.analysis.IndexAnalyzers; import org.elasticsearch.index.analysis.NamedAnalyzer; @@ -193,7 +193,7 @@ public static AnnotatedText parse (String textPlusMarkup) { String[] kv = pair.split("="); try { if (kv.length == 2) { - throw new ElasticsearchParseException("key=value pairs are not supported in annotations"); + throw new OpenSearchParseException("key=value pairs are not supported in annotations"); } if (kv.length == 1) { //Check "=" sign wasn't in the pair string @@ -206,7 +206,7 @@ public static AnnotatedText parse (String textPlusMarkup) { annotations.add(new AnnotationToken(startOffset, endOffset, value)); } } catch (UnsupportedEncodingException e) { - throw new ElasticsearchParseException("Unsupported encoding parsing annotated text", e); + throw new OpenSearchParseException("Unsupported encoding parsing annotated text", e); } } } diff --git a/plugins/mapper-annotated-text/src/test/java/org/elasticsearch/index/mapper/annotatedtext/AnnotatedTextParsingTests.java b/plugins/mapper-annotated-text/src/test/java/org/elasticsearch/index/mapper/annotatedtext/AnnotatedTextParsingTests.java index 4df44df5cd514..cf6f200f5f54f 100644 --- a/plugins/mapper-annotated-text/src/test/java/org/elasticsearch/index/mapper/annotatedtext/AnnotatedTextParsingTests.java +++ b/plugins/mapper-annotated-text/src/test/java/org/elasticsearch/index/mapper/annotatedtext/AnnotatedTextParsingTests.java @@ -19,7 +19,7 @@ package org.elasticsearch.index.mapper.annotatedtext; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.index.mapper.annotatedtext.AnnotatedTextFieldMapper.AnnotatedText; import org.elasticsearch.index.mapper.annotatedtext.AnnotatedTextFieldMapper.AnnotatedText.AnnotationToken; import org.elasticsearch.test.ESTestCase; @@ -29,7 +29,7 @@ import static org.hamcrest.Matchers.equalTo; public class AnnotatedTextParsingTests extends ESTestCase { - + private void checkParsing(String markup, String expectedPlainText, AnnotationToken... expectedTokens) { AnnotatedText at = AnnotatedText.parse(markup); assertEquals(expectedPlainText, at.textMinusMarkup); @@ -38,36 +38,36 @@ private void checkParsing(String markup, String expectedPlainText, AnnotationTok for (int i = 0; i < expectedTokens.length; i++) { assertEquals(expectedTokens[i], actualAnnotations.get(i)); } - } - + } + public void testSingleValueMarkup() { checkParsing("foo [bar](Y)", "foo bar", new AnnotationToken(4,7,"Y")); - } - + } + public void testMultiValueMarkup() { - checkParsing("foo [bar](Y&B)", "foo bar", new AnnotationToken(4,7,"Y"), + checkParsing("foo [bar](Y&B)", "foo bar", new AnnotationToken(4,7,"Y"), new AnnotationToken(4,7,"B")); - } - + } + public void testBlankTextAnnotation() { - checkParsing("It sounded like this:[](theSoundOfOneHandClapping)", "It sounded like this:", + checkParsing("It sounded like this:[](theSoundOfOneHandClapping)", "It sounded like this:", new AnnotationToken(21,21,"theSoundOfOneHandClapping")); - } - + } + public void testMissingBracket() { checkParsing("[foo](MissingEndBracket bar", "[foo](MissingEndBracket bar", new AnnotationToken[0]); } - + public void testAnnotationWithType() { - Exception expectedException = expectThrows(ElasticsearchParseException.class, + Exception expectedException = expectThrows(OpenSearchParseException.class, () -> checkParsing("foo [bar](type=foo) baz", "foo bar baz", new AnnotationToken(4,7, "noType"))); assertThat(expectedException.getMessage(), equalTo("key=value pairs are not supported in annotations")); } - + public void testMissingValue() { checkParsing("[foo]() bar", "foo bar", new AnnotationToken[0]); - } - + } + } diff --git a/server/src/internalClusterTest/java/org/elasticsearch/cluster/coordination/RareClusterStateIT.java b/server/src/internalClusterTest/java/org/elasticsearch/cluster/coordination/RareClusterStateIT.java index 6eb68f4918e87..4115ed4e5ee54 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/cluster/coordination/RareClusterStateIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/cluster/coordination/RareClusterStateIT.java @@ -19,7 +19,7 @@ package org.elasticsearch.cluster.coordination; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.Version; import org.elasticsearch.action.ActionFuture; import org.elasticsearch.action.ActionRequest; @@ -251,7 +251,7 @@ public void testDelayedMappingPropagationOnPrimary() throws Exception { Object properties; try { properties = typeMappings.getSourceAsMap().get("properties"); - } catch (ElasticsearchParseException e) { + } catch (OpenSearchParseException e) { throw new AssertionError(e); } assertNotNull(properties); diff --git a/server/src/internalClusterTest/java/org/elasticsearch/ingest/IngestClientIT.java b/server/src/internalClusterTest/java/org/elasticsearch/ingest/IngestClientIT.java index c3fc6e3dc94fb..8dd261773a498 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/ingest/IngestClientIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/ingest/IngestClientIT.java @@ -20,7 +20,7 @@ package org.elasticsearch.ingest; import org.elasticsearch.OpenSearchException; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.ExceptionsHelper; import org.elasticsearch.action.DocWriteResponse; import org.elasticsearch.action.bulk.BulkItemResponse; @@ -269,7 +269,7 @@ public void testPutWithPipelineFactoryError() throws Exception { .endArray() .endObject()); PutPipelineRequest putPipelineRequest = new PutPipelineRequest("_id2", source, XContentType.JSON); - Exception e = expectThrows(ElasticsearchParseException.class, + Exception e = expectThrows(OpenSearchParseException.class, () -> client().admin().cluster().putPipeline(putPipelineRequest).actionGet()); assertThat(e.getMessage(), equalTo("processor [test] doesn't support one or more provided configuration parameters [unused]")); diff --git a/server/src/internalClusterTest/java/org/elasticsearch/ingest/IngestProcessorNotInstalledOnAllNodesIT.java b/server/src/internalClusterTest/java/org/elasticsearch/ingest/IngestProcessorNotInstalledOnAllNodesIT.java index 4c2352bfebe7d..a37706e17301d 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/ingest/IngestProcessorNotInstalledOnAllNodesIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/ingest/IngestProcessorNotInstalledOnAllNodesIT.java @@ -19,7 +19,7 @@ package org.elasticsearch.ingest; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.action.support.master.AcknowledgedResponse; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.xcontent.XContentType; @@ -71,7 +71,7 @@ public void testFailPipelineCreation() throws Exception { try { client().admin().cluster().preparePutPipeline("_id", pipelineSource, XContentType.JSON).get(); fail("exception expected"); - } catch (ElasticsearchParseException e) { + } catch (OpenSearchParseException e) { assertThat(e.getMessage(), containsString("Processor type [test] is not installed on node")); } } @@ -84,7 +84,7 @@ public void testFailPipelineCreationProcessorNotInstalledOnMasterNode() throws E try { client().admin().cluster().preparePutPipeline("_id", pipelineSource, XContentType.JSON).get(); fail("exception expected"); - } catch (ElasticsearchParseException e) { + } catch (OpenSearchParseException e) { assertThat(e.getMessage(), equalTo("No processor type exists with name [test]")); } } diff --git a/server/src/main/java/org/elasticsearch/OpenSearchException.java b/server/src/main/java/org/elasticsearch/OpenSearchException.java index cadfe4872f296..405ea2697473e 100644 --- a/server/src/main/java/org/elasticsearch/OpenSearchException.java +++ b/server/src/main/java/org/elasticsearch/OpenSearchException.java @@ -799,8 +799,8 @@ private enum OpenSearchExceptionHandle { org.elasticsearch.indices.IndexPrimaryShardNotAllocatedException::new, 33, UNKNOWN_VERSION_ADDED), TRANSPORT_EXCEPTION(org.elasticsearch.transport.TransportException.class, org.elasticsearch.transport.TransportException::new, 34, UNKNOWN_VERSION_ADDED), - ELASTICSEARCH_PARSE_EXCEPTION(org.elasticsearch.ElasticsearchParseException.class, - org.elasticsearch.ElasticsearchParseException::new, 35, UNKNOWN_VERSION_ADDED), + ELASTICSEARCH_PARSE_EXCEPTION(org.elasticsearch.OpenSearchParseException.class, + org.elasticsearch.OpenSearchParseException::new, 35, UNKNOWN_VERSION_ADDED), SEARCH_EXCEPTION(org.elasticsearch.search.SearchException.class, org.elasticsearch.search.SearchException::new, 36, UNKNOWN_VERSION_ADDED), MAPPER_EXCEPTION(org.elasticsearch.index.mapper.MapperException.class, diff --git a/server/src/main/java/org/elasticsearch/ElasticsearchParseException.java b/server/src/main/java/org/elasticsearch/OpenSearchParseException.java similarity index 80% rename from server/src/main/java/org/elasticsearch/ElasticsearchParseException.java rename to server/src/main/java/org/elasticsearch/OpenSearchParseException.java index a7bad895f84e5..8b301c5628a26 100644 --- a/server/src/main/java/org/elasticsearch/ElasticsearchParseException.java +++ b/server/src/main/java/org/elasticsearch/OpenSearchParseException.java @@ -27,17 +27,17 @@ /** * Unchecked exception that is translated into a {@code 400 BAD REQUEST} error when it bubbles out over HTTP. */ -public class ElasticsearchParseException extends OpenSearchException { +public class OpenSearchParseException extends OpenSearchException { - public ElasticsearchParseException(String msg, Object... args) { + public OpenSearchParseException(String msg, Object... args) { super(msg, args); } - public ElasticsearchParseException(String msg, Throwable cause, Object... args) { + public OpenSearchParseException(String msg, Throwable cause, Object... args) { super(msg, cause, args); } - public ElasticsearchParseException(StreamInput in) throws IOException { + public OpenSearchParseException(StreamInput in) throws IOException { super(in); } @Override diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/status/SnapshotIndexShardStatus.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/status/SnapshotIndexShardStatus.java index 27c9b41fe8d9a..fa73a0eac82fc 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/status/SnapshotIndexShardStatus.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/status/SnapshotIndexShardStatus.java @@ -19,7 +19,7 @@ package org.elasticsearch.action.admin.cluster.snapshots.status; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.action.support.broadcast.BroadcastShardResponse; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.common.ParseField; @@ -177,7 +177,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws try { stage = SnapshotIndexShardStage.valueOf(rawStage); } catch (IllegalArgumentException iae) { - throw new ElasticsearchParseException( + throw new OpenSearchParseException( "failed to parse snapshot index shard status [{}][{}], unknown stage [{}]", shard.getIndex().getName(), shard.getId(), rawStage); } @@ -195,7 +195,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws try { shard = Integer.parseInt(shardName); } catch (NumberFormatException nfe) { - throw new ElasticsearchParseException( + throw new OpenSearchParseException( "failed to parse snapshot index shard status [{}], expected numeric shard id but got [{}]", indexId, shardName); } ShardId shardId = new ShardId(new Index(indexId, IndexMetadata.INDEX_UUID_NA_VALUE), shard); diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/create/CreateIndexRequest.java b/server/src/main/java/org/elasticsearch/action/admin/indices/create/CreateIndexRequest.java index 561817d08915f..ffa6e5374854b 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/create/CreateIndexRequest.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/create/CreateIndexRequest.java @@ -20,7 +20,7 @@ package org.elasticsearch.action.admin.indices.create; import org.elasticsearch.OpenSearchGenerationException; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.Version; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.IndicesRequest; @@ -339,7 +339,7 @@ public CreateIndexRequest aliases(BytesReference source) { } return this; } catch(IOException e) { - throw new ElasticsearchParseException("Failed to parse aliases", e); + throw new OpenSearchParseException("Failed to parse aliases", e); } } @@ -397,7 +397,7 @@ public CreateIndexRequest source(Map source, DeprecationHandler depre String name = entry.getKey(); if (SETTINGS.match(name, deprecationHandler)) { if (entry.getValue() instanceof Map == false) { - throw new ElasticsearchParseException("key [settings] must be an object"); + throw new OpenSearchParseException("key [settings] must be an object"); } settings((Map) entry.getValue()); } else if (MAPPINGS.match(name, deprecationHandler)) { @@ -408,7 +408,7 @@ public CreateIndexRequest source(Map source, DeprecationHandler depre } else if (ALIASES.match(name, deprecationHandler)) { aliases((Map) entry.getValue()); } else { - throw new ElasticsearchParseException("unknown key [{}] for create index", name); + throw new OpenSearchParseException("unknown key [{}] for create index", name); } } return this; diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/template/put/PutIndexTemplateRequest.java b/server/src/main/java/org/elasticsearch/action/admin/indices/template/put/PutIndexTemplateRequest.java index 826f18ba37c4d..0adda216cfe49 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/template/put/PutIndexTemplateRequest.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/template/put/PutIndexTemplateRequest.java @@ -19,7 +19,7 @@ package org.elasticsearch.action.admin.indices.template.put; import org.elasticsearch.OpenSearchGenerationException; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.Version; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.IndicesRequest; @@ -374,7 +374,7 @@ public PutIndexTemplateRequest source(Map templateSource) { } else if (name.equals("aliases")) { aliases((Map) entry.getValue()); } else { - throw new ElasticsearchParseException("unknown key [{}] in the template ", name); + throw new OpenSearchParseException("unknown key [{}] in the template ", name); } } return this; @@ -453,7 +453,7 @@ public PutIndexTemplateRequest aliases(BytesReference source) { } return this; } catch(IOException e) { - throw new ElasticsearchParseException("Failed to parse aliases", e); + throw new OpenSearchParseException("Failed to parse aliases", e); } } diff --git a/server/src/main/java/org/elasticsearch/action/bulk/TransportBulkAction.java b/server/src/main/java/org/elasticsearch/action/bulk/TransportBulkAction.java index 555528fdd627a..2879d069bcca5 100644 --- a/server/src/main/java/org/elasticsearch/action/bulk/TransportBulkAction.java +++ b/server/src/main/java/org/elasticsearch/action/bulk/TransportBulkAction.java @@ -23,7 +23,7 @@ import org.apache.logging.log4j.Logger; import org.apache.lucene.util.SparseFixedBitSet; import org.elasticsearch.Assertions; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.ExceptionsHelper; import org.elasticsearch.ResourceAlreadyExistsException; import org.elasticsearch.Version; @@ -505,7 +505,7 @@ protected void doRun() { break; default: throw new AssertionError("request type not supported: [" + docWriteRequest.opType() + "]"); } - } catch (ElasticsearchParseException | IllegalArgumentException | RoutingMissingException e) { + } catch (OpenSearchParseException | IllegalArgumentException | RoutingMissingException e) { BulkItemResponse.Failure failure = new BulkItemResponse.Failure(concreteIndex.getName(), docWriteRequest.type(), docWriteRequest.id(), e); BulkItemResponse bulkItemResponse = new BulkItemResponse(i, docWriteRequest.opType(), failure); diff --git a/server/src/main/java/org/elasticsearch/action/get/GetResponse.java b/server/src/main/java/org/elasticsearch/action/get/GetResponse.java index c3362f7fc650c..ea2062870128c 100644 --- a/server/src/main/java/org/elasticsearch/action/get/GetResponse.java +++ b/server/src/main/java/org/elasticsearch/action/get/GetResponse.java @@ -19,7 +19,7 @@ package org.elasticsearch.action.get; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.action.ActionResponse; import org.elasticsearch.common.ParsingException; import org.elasticsearch.common.Strings; @@ -145,7 +145,7 @@ public String getSourceAsString() { /** * The source of the document (As a map). */ - public Map getSourceAsMap() throws ElasticsearchParseException { + public Map getSourceAsMap() throws OpenSearchParseException { return getResult.sourceAsMap(); } diff --git a/server/src/main/java/org/elasticsearch/action/get/MultiGetRequest.java b/server/src/main/java/org/elasticsearch/action/get/MultiGetRequest.java index ef8ea8067f97c..5aa8499887dc7 100644 --- a/server/src/main/java/org/elasticsearch/action/get/MultiGetRequest.java +++ b/server/src/main/java/org/elasticsearch/action/get/MultiGetRequest.java @@ -19,7 +19,7 @@ package org.elasticsearch.action.get; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.Version; import org.elasticsearch.action.ActionRequest; import org.elasticsearch.action.ActionRequestValidationException; @@ -453,10 +453,10 @@ private static void parseDocuments(XContentParser parser, List items, @Nul fetchSourceContext = new FetchSourceContext(fetchSourceContext.fetchSource(), new String[]{parser.text()}, fetchSourceContext.excludes()); } else { - throw new ElasticsearchParseException("illegal type for _source: [{}]", token); + throw new OpenSearchParseException("illegal type for _source: [{}]", token); } } else { - throw new ElasticsearchParseException("failed to parse multi get request. unknown field [{}]", currentFieldName); + throw new OpenSearchParseException("failed to parse multi get request. unknown field [{}]", currentFieldName); } } else if (token == Token.START_ARRAY) { if (FIELDS.match(currentFieldName, parser.getDeprecationHandler())) { @@ -488,7 +488,7 @@ private static void parseDocuments(XContentParser parser, List items, @Nul } else if ("excludes".equals(currentFieldName) || "exclude".equals(currentFieldName)) { currentList = excludes != null ? excludes : (excludes = new ArrayList<>(2)); } else { - throw new ElasticsearchParseException("source definition may not contain [{}]", parser.text()); + throw new OpenSearchParseException("source definition may not contain [{}]", parser.text()); } } else if (token == Token.START_ARRAY) { while ((token = parser.nextToken()) != Token.END_ARRAY) { @@ -497,7 +497,7 @@ private static void parseDocuments(XContentParser parser, List items, @Nul } else if (token.isValue()) { currentList.add(parser.text()); } else { - throw new ElasticsearchParseException("unexpected token while parsing source settings"); + throw new OpenSearchParseException("unexpected token while parsing source settings"); } } diff --git a/server/src/main/java/org/elasticsearch/action/support/IndicesOptions.java b/server/src/main/java/org/elasticsearch/action/support/IndicesOptions.java index 676112c2eb88d..fe13eb358b10a 100644 --- a/server/src/main/java/org/elasticsearch/action/support/IndicesOptions.java +++ b/server/src/main/java/org/elasticsearch/action/support/IndicesOptions.java @@ -18,8 +18,8 @@ */ package org.elasticsearch.action.support; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.Version; -import org.elasticsearch.ElasticsearchParseException; import org.elasticsearch.common.ParseField; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; @@ -395,7 +395,7 @@ public static IndicesOptions fromXContent(XContentParser parser) throws IOExcept Token token = parser.currentToken() == Token.START_OBJECT ? parser.currentToken() : parser.nextToken(); String currentFieldName = null; if (token != Token.START_OBJECT) { - throw new ElasticsearchParseException("expected START_OBJECT as the token but was " + token); + throw new OpenSearchParseException("expected START_OBJECT as the token but was " + token); } while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) { if (token == XContentParser.Token.FIELD_NAME) { @@ -408,15 +408,15 @@ public static IndicesOptions fromXContent(XContentParser parser) throws IOExcept if (token.isValue()) { WildcardStates.updateSetForValue(wildcardStates, parser.text()); } else { - throw new ElasticsearchParseException("expected values within array for " + + throw new OpenSearchParseException("expected values within array for " + EXPAND_WILDCARDS_FIELD.getPreferredName()); } } } else { - throw new ElasticsearchParseException("already parsed expand_wildcards"); + throw new OpenSearchParseException("already parsed expand_wildcards"); } } else { - throw new ElasticsearchParseException(EXPAND_WILDCARDS_FIELD.getPreferredName() + + throw new OpenSearchParseException(EXPAND_WILDCARDS_FIELD.getPreferredName() + " is the only field that is an array in IndicesOptions"); } } else if (token.isValue()) { @@ -425,7 +425,7 @@ public static IndicesOptions fromXContent(XContentParser parser) throws IOExcept wildcardStates = EnumSet.noneOf(WildcardStates.class); WildcardStates.updateSetForValue(wildcardStates, parser.text()); } else { - throw new ElasticsearchParseException("already parsed expand_wildcards"); + throw new OpenSearchParseException("already parsed expand_wildcards"); } } else if (IGNORE_UNAVAILABLE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { ignoreUnavailable = parser.booleanValue(); @@ -434,24 +434,24 @@ public static IndicesOptions fromXContent(XContentParser parser) throws IOExcept } else if (IGNORE_THROTTLED_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { ignoreThrottled = parser.booleanValue(); } else { - throw new ElasticsearchParseException("could not read indices options. unexpected index option [" + + throw new OpenSearchParseException("could not read indices options. unexpected index option [" + currentFieldName + "]"); } } else { - throw new ElasticsearchParseException("could not read indices options. unexpected object field [" + + throw new OpenSearchParseException("could not read indices options. unexpected object field [" + currentFieldName + "]"); } } if (wildcardStates == null) { - throw new ElasticsearchParseException("indices options xcontent did not contain " + EXPAND_WILDCARDS_FIELD.getPreferredName()); + throw new OpenSearchParseException("indices options xcontent did not contain " + EXPAND_WILDCARDS_FIELD.getPreferredName()); } if (ignoreUnavailable == null) { - throw new ElasticsearchParseException("indices options xcontent did not contain " + + throw new OpenSearchParseException("indices options xcontent did not contain " + IGNORE_UNAVAILABLE_FIELD.getPreferredName()); } if (allowNoIndices == null) { - throw new ElasticsearchParseException("indices options xcontent did not contain " + + throw new OpenSearchParseException("indices options xcontent did not contain " + ALLOW_NO_INDICES_FIELD.getPreferredName()); } diff --git a/server/src/main/java/org/elasticsearch/action/termvectors/MultiTermVectorsRequest.java b/server/src/main/java/org/elasticsearch/action/termvectors/MultiTermVectorsRequest.java index b476d67300f34..cdb5282ab9937 100644 --- a/server/src/main/java/org/elasticsearch/action/termvectors/MultiTermVectorsRequest.java +++ b/server/src/main/java/org/elasticsearch/action/termvectors/MultiTermVectorsRequest.java @@ -19,7 +19,7 @@ package org.elasticsearch.action.termvectors; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.action.ActionRequest; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.CompositeIndicesRequest; @@ -128,16 +128,16 @@ public void add(TermVectorsRequest template, @Nullable XContentParser parser) th ids.add(parser.text()); } } else { - throw new ElasticsearchParseException("no parameter named [{}] and type ARRAY", currentFieldName); + throw new OpenSearchParseException("no parameter named [{}] and type ARRAY", currentFieldName); } } else if (token == XContentParser.Token.START_OBJECT && currentFieldName != null) { if ("parameters".equals(currentFieldName)) { TermVectorsRequest.parseRequest(template, parser); } else { - throw new ElasticsearchParseException("no parameter named [{}] and type OBJECT", currentFieldName); + throw new OpenSearchParseException("no parameter named [{}] and type OBJECT", currentFieldName); } } else if (currentFieldName != null) { - throw new ElasticsearchParseException("_mtermvectors: Parameter [{}] not supported", currentFieldName); + throw new OpenSearchParseException("_mtermvectors: Parameter [{}] not supported", currentFieldName); } } } diff --git a/server/src/main/java/org/elasticsearch/action/termvectors/TermVectorsRequest.java b/server/src/main/java/org/elasticsearch/action/termvectors/TermVectorsRequest.java index d66eda89aa984..a1a22c576b7ff 100644 --- a/server/src/main/java/org/elasticsearch/action/termvectors/TermVectorsRequest.java +++ b/server/src/main/java/org/elasticsearch/action/termvectors/TermVectorsRequest.java @@ -19,7 +19,7 @@ package org.elasticsearch.action.termvectors; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.Version; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.RealtimeRequest; @@ -590,7 +590,7 @@ public static void parseRequest(TermVectorsRequest termVectorsRequest, XContentP fields.add(parser.text()); } } else { - throw new ElasticsearchParseException("failed to parse term vectors request. field [fields] must be an array"); + throw new OpenSearchParseException("failed to parse term vectors request. field [fields] must be an array"); } } else if (OFFSETS.match(currentFieldName, parser.getDeprecationHandler())) { termVectorsRequest.offsets(parser.booleanValue()); @@ -617,13 +617,13 @@ public static void parseRequest(TermVectorsRequest termVectorsRequest, XContentP RestTermVectorsAction.TYPES_DEPRECATION_MESSAGE); } else if (ID.match(currentFieldName, parser.getDeprecationHandler())) { if (termVectorsRequest.doc != null) { - throw new ElasticsearchParseException("failed to parse term vectors request. " + + throw new OpenSearchParseException("failed to parse term vectors request. " + "either [id] or [doc] can be specified, but not both!"); } termVectorsRequest.id = parser.text(); } else if (DOC.match(currentFieldName, parser.getDeprecationHandler())) { if (termVectorsRequest.id != null) { - throw new ElasticsearchParseException("failed to parse term vectors request. " + + throw new OpenSearchParseException("failed to parse term vectors request. " + "either [id] or [doc] can be specified, but not both!"); } termVectorsRequest.doc(jsonBuilder().copyCurrentStructure(parser)); @@ -634,7 +634,7 @@ public static void parseRequest(TermVectorsRequest termVectorsRequest, XContentP } else if (VERSION_TYPE.match(currentFieldName, parser.getDeprecationHandler())) { termVectorsRequest.versionType = VersionType.fromString(parser.text()); } else { - throw new ElasticsearchParseException("failed to parse term vectors request. unknown field [{}]", currentFieldName); + throw new OpenSearchParseException("failed to parse term vectors request. unknown field [{}]", currentFieldName); } } } @@ -650,7 +650,7 @@ public static Map readPerFieldAnalyzer(Map map) if (e.getValue() instanceof String) { mapStrStr.put(e.getKey(), (String) e.getValue()); } else { - throw new ElasticsearchParseException("expecting the analyzer at [{}] to be a String, but found [{}] instead", + throw new OpenSearchParseException("expecting the analyzer at [{}] to be a String, but found [{}] instead", e.getKey(), e.getValue().getClass()); } } @@ -680,7 +680,7 @@ private static FilterSettings readFilterSettings(XContentParser parser) throws I } else if (currentFieldName.equals("max_word_length")) { settings.maxWordLength = parser.intValue(); } else { - throw new ElasticsearchParseException("failed to parse term vectors request. " + + throw new OpenSearchParseException("failed to parse term vectors request. " + "the field [{}] is not valid for filter parameter for term vector request", currentFieldName); } } diff --git a/server/src/main/java/org/elasticsearch/cluster/metadata/IndexNameExpressionResolver.java b/server/src/main/java/org/elasticsearch/cluster/metadata/IndexNameExpressionResolver.java index fda42924d9312..f60d58cd62136 100644 --- a/server/src/main/java/org/elasticsearch/cluster/metadata/IndexNameExpressionResolver.java +++ b/server/src/main/java/org/elasticsearch/cluster/metadata/IndexNameExpressionResolver.java @@ -19,7 +19,7 @@ package org.elasticsearch.cluster.metadata; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.Version; import org.elasticsearch.action.IndicesRequest; import org.elasticsearch.action.support.IndicesOptions; @@ -1123,7 +1123,7 @@ String resolveExpression(String expression, final Context context) { inDateFormat = true; inPlaceHolderSb.append(c); } else { - throw new ElasticsearchParseException("invalid dynamic name expression [{}]." + + throw new OpenSearchParseException("invalid dynamic name expression [{}]." + " invalid character in placeholder at position [{}]", new String(text, from, length), i); } break; @@ -1147,11 +1147,11 @@ String resolveExpression(String expression, final Context context) { timeZone = ZoneOffset.UTC; } else { if (inPlaceHolderString.lastIndexOf(RIGHT_BOUND) != inPlaceHolderString.length() - 1) { - throw new ElasticsearchParseException("invalid dynamic name expression [{}]. missing closing `}`" + + throw new OpenSearchParseException("invalid dynamic name expression [{}]. missing closing `}`" + " for date math format", inPlaceHolderString); } if (dateTimeFormatLeftBoundIndex == inPlaceHolderString.length() - 2) { - throw new ElasticsearchParseException("invalid dynamic name expression [{}]. missing date format", + throw new OpenSearchParseException("invalid dynamic name expression [{}]. missing date format", inPlaceHolderString); } mathExpression = inPlaceHolderString.substring(0, dateTimeFormatLeftBoundIndex); @@ -1194,7 +1194,7 @@ String resolveExpression(String expression, final Context context) { case RIGHT_BOUND: if (!escapedChar) { - throw new ElasticsearchParseException("invalid dynamic name expression [{}]." + + throw new OpenSearchParseException("invalid dynamic name expression [{}]." + " invalid character at position [{}]. `{` and `}` are reserved characters and" + " should be escaped when used as part of the index name using `\\` (e.g. `\\{text\\}`)", new String(text, from, length), i); @@ -1206,11 +1206,11 @@ String resolveExpression(String expression, final Context context) { } if (inPlaceHolder) { - throw new ElasticsearchParseException("invalid dynamic name expression [{}]. date math placeholder is open ended", + throw new OpenSearchParseException("invalid dynamic name expression [{}]. date math placeholder is open ended", new String(text, from, length)); } if (beforePlaceHolderSb.length() == 0) { - throw new ElasticsearchParseException("nothing captured"); + throw new OpenSearchParseException("nothing captured"); } return beforePlaceHolderSb.toString(); } diff --git a/server/src/main/java/org/elasticsearch/cluster/metadata/IndexTemplateMetadata.java b/server/src/main/java/org/elasticsearch/cluster/metadata/IndexTemplateMetadata.java index 73887ad61f358..44c8271304d70 100644 --- a/server/src/main/java/org/elasticsearch/cluster/metadata/IndexTemplateMetadata.java +++ b/server/src/main/java/org/elasticsearch/cluster/metadata/IndexTemplateMetadata.java @@ -20,7 +20,7 @@ import com.carrotsearch.hppc.cursors.ObjectCursor; import com.carrotsearch.hppc.cursors.ObjectObjectCursor; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.Version; import org.elasticsearch.cluster.AbstractDiffable; import org.elasticsearch.cluster.Diff; @@ -498,7 +498,7 @@ public static IndexTemplateMetadata fromXContent(XContentParser parser, String t builder.putAlias(AliasMetadata.Builder.fromXContent(parser)); } } else { - throw new ElasticsearchParseException("unknown key [{}] for index template", currentFieldName); + throw new OpenSearchParseException("unknown key [{}] for index template", currentFieldName); } } else if (token == XContentParser.Token.START_ARRAY) { if ("mappings".equals(currentFieldName)) { diff --git a/server/src/main/java/org/elasticsearch/cluster/metadata/MappingMetadata.java b/server/src/main/java/org/elasticsearch/cluster/metadata/MappingMetadata.java index 7c43bbc3e3b71..fa310400c1ac5 100644 --- a/server/src/main/java/org/elasticsearch/cluster/metadata/MappingMetadata.java +++ b/server/src/main/java/org/elasticsearch/cluster/metadata/MappingMetadata.java @@ -19,7 +19,7 @@ package org.elasticsearch.cluster.metadata; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.Version; import org.elasticsearch.cluster.AbstractDiffable; import org.elasticsearch.cluster.Diff; @@ -144,7 +144,7 @@ public CompressedXContent source() { /** * Converts the serialized compressed form of the mappings into a parsed map. */ - public Map sourceAsMap() throws ElasticsearchParseException { + public Map sourceAsMap() throws OpenSearchParseException { Map mapping = XContentHelper.convertToMap(source.compressedReference(), true).v2(); if (mapping.size() == 1 && mapping.containsKey(type())) { // the type name is the root value, reduce it @@ -156,7 +156,7 @@ public Map sourceAsMap() throws ElasticsearchParseException { /** * Converts the serialized compressed form of the mappings into a parsed map. */ - public Map getSourceAsMap() throws ElasticsearchParseException { + public Map getSourceAsMap() throws OpenSearchParseException { return sourceAsMap(); } diff --git a/server/src/main/java/org/elasticsearch/cluster/metadata/RepositoriesMetadata.java b/server/src/main/java/org/elasticsearch/cluster/metadata/RepositoriesMetadata.java index 91150650a1a35..fa1d51ea8ed9d 100644 --- a/server/src/main/java/org/elasticsearch/cluster/metadata/RepositoriesMetadata.java +++ b/server/src/main/java/org/elasticsearch/cluster/metadata/RepositoriesMetadata.java @@ -19,7 +19,7 @@ package org.elasticsearch.cluster.metadata; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.Version; import org.elasticsearch.cluster.AbstractNamedDiffable; import org.elasticsearch.cluster.NamedDiff; @@ -186,7 +186,7 @@ public static RepositoriesMetadata fromXContent(XContentParser parser) throws IO if (token == XContentParser.Token.FIELD_NAME) { String name = parser.currentName(); if (parser.nextToken() != XContentParser.Token.START_OBJECT) { - throw new ElasticsearchParseException("failed to parse repository [{}], expected object", name); + throw new OpenSearchParseException("failed to parse repository [{}], expected object", name); } String type = null; Settings settings = Settings.EMPTY; @@ -197,38 +197,38 @@ public static RepositoriesMetadata fromXContent(XContentParser parser) throws IO String currentFieldName = parser.currentName(); if ("type".equals(currentFieldName)) { if (parser.nextToken() != XContentParser.Token.VALUE_STRING) { - throw new ElasticsearchParseException("failed to parse repository [{}], unknown type", name); + throw new OpenSearchParseException("failed to parse repository [{}], unknown type", name); } type = parser.text(); } else if ("settings".equals(currentFieldName)) { if (parser.nextToken() != XContentParser.Token.START_OBJECT) { - throw new ElasticsearchParseException("failed to parse repository [{}], incompatible params", name); + throw new OpenSearchParseException("failed to parse repository [{}], incompatible params", name); } settings = Settings.fromXContent(parser); } else if ("generation".equals(currentFieldName)) { if (parser.nextToken() != XContentParser.Token.VALUE_NUMBER) { - throw new ElasticsearchParseException("failed to parse repository [{}], unknown type", name); + throw new OpenSearchParseException("failed to parse repository [{}], unknown type", name); } generation = parser.longValue(); } else if ("pending_generation".equals(currentFieldName)) { if (parser.nextToken() != XContentParser.Token.VALUE_NUMBER) { - throw new ElasticsearchParseException("failed to parse repository [{}], unknown type", name); + throw new OpenSearchParseException("failed to parse repository [{}], unknown type", name); } pendingGeneration = parser.longValue(); } else { - throw new ElasticsearchParseException("failed to parse repository [{}], unknown field [{}]", + throw new OpenSearchParseException("failed to parse repository [{}], unknown field [{}]", name, currentFieldName); } } else { - throw new ElasticsearchParseException("failed to parse repository [{}]", name); + throw new OpenSearchParseException("failed to parse repository [{}]", name); } } if (type == null) { - throw new ElasticsearchParseException("failed to parse repository [{}], missing repository type", name); + throw new OpenSearchParseException("failed to parse repository [{}], missing repository type", name); } repository.add(new RepositoryMetadata(name, type, settings, generation, pendingGeneration)); } else { - throw new ElasticsearchParseException("failed to parse repositories"); + throw new OpenSearchParseException("failed to parse repositories"); } } return new RepositoriesMetadata(repository); diff --git a/server/src/main/java/org/elasticsearch/cluster/routing/allocation/DiskThresholdSettings.java b/server/src/main/java/org/elasticsearch/cluster/routing/allocation/DiskThresholdSettings.java index 7d97584f8ca12..74a8eb761d730 100644 --- a/server/src/main/java/org/elasticsearch/cluster/routing/allocation/DiskThresholdSettings.java +++ b/server/src/main/java/org/elasticsearch/cluster/routing/allocation/DiskThresholdSettings.java @@ -19,7 +19,7 @@ package org.elasticsearch.cluster.routing.allocation; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.common.Strings; import org.elasticsearch.common.settings.ClusterSettings; import org.elasticsearch.common.settings.Setting; @@ -183,12 +183,12 @@ private static void doValidate(String low, String high, String flood) { try { doValidateAsPercentage(low, high, flood); return; // early return so that we do not try to parse as bytes - } catch (final ElasticsearchParseException e) { + } catch (final OpenSearchParseException e) { // swallow as we are now going to try to parse as bytes } try { doValidateAsBytes(low, high, flood); - } catch (final ElasticsearchParseException e) { + } catch (final OpenSearchParseException e) { final String message = String.format( Locale.ROOT, "unable to consistently parse [%s=%s], [%s=%s], and [%s=%s] as percentage or bytes", @@ -350,7 +350,7 @@ private static double thresholdPercentageFromWatermark(String watermark) { /** * Attempts to parse the watermark into a percentage, returning 100.0% if it can not be parsed and the specified lenient parameter is - * true, otherwise throwing an {@link ElasticsearchParseException}. + * true, otherwise throwing an {@link OpenSearchParseException}. * * @param watermark the watermark to parse as a percentage * @param lenient true if lenient parsing should be applied @@ -359,7 +359,7 @@ private static double thresholdPercentageFromWatermark(String watermark) { private static double thresholdPercentageFromWatermark(String watermark, boolean lenient) { try { return RatioValue.parseRatioValue(watermark).getAsPercent(); - } catch (ElasticsearchParseException ex) { + } catch (OpenSearchParseException ex) { // NOTE: this is not end-user leniency, since up above we check that it's a valid byte or percentage, and then store the two // cases separately if (lenient) { @@ -379,7 +379,7 @@ private static ByteSizeValue thresholdBytesFromWatermark(String watermark, Strin /** * Attempts to parse the watermark into a {@link ByteSizeValue}, returning zero bytes if it can not be parsed and the specified lenient - * parameter is true, otherwise throwing an {@link ElasticsearchParseException}. + * parameter is true, otherwise throwing an {@link OpenSearchParseException}. * * @param watermark the watermark to parse as a byte size * @param settingName the name of the setting @@ -389,7 +389,7 @@ private static ByteSizeValue thresholdBytesFromWatermark(String watermark, Strin private static ByteSizeValue thresholdBytesFromWatermark(String watermark, String settingName, boolean lenient) { try { return ByteSizeValue.parseBytesSizeValue(watermark, settingName); - } catch (ElasticsearchParseException ex) { + } catch (OpenSearchParseException ex) { // NOTE: this is not end-user leniency, since up above we check that it's a valid byte or percentage, and then store the two // cases separately if (lenient) { @@ -406,10 +406,10 @@ private static ByteSizeValue thresholdBytesFromWatermark(String watermark, Strin private static String validWatermarkSetting(String watermark, String settingName) { try { RatioValue.parseRatioValue(watermark); - } catch (ElasticsearchParseException e) { + } catch (OpenSearchParseException e) { try { ByteSizeValue.parseBytesSizeValue(watermark, settingName); - } catch (ElasticsearchParseException ex) { + } catch (OpenSearchParseException ex) { ex.addSuppressed(e); throw ex; } diff --git a/server/src/main/java/org/elasticsearch/cluster/routing/allocation/command/AllocationCommands.java b/server/src/main/java/org/elasticsearch/cluster/routing/allocation/command/AllocationCommands.java index 323a4aab4b093..be9f4016d95cc 100644 --- a/server/src/main/java/org/elasticsearch/cluster/routing/allocation/command/AllocationCommands.java +++ b/server/src/main/java/org/elasticsearch/cluster/routing/allocation/command/AllocationCommands.java @@ -19,8 +19,8 @@ package org.elasticsearch.cluster.routing.allocation.command; -import org.elasticsearch.ElasticsearchParseException; import org.elasticsearch.OpenSearchException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.cluster.routing.allocation.RoutingAllocation; import org.elasticsearch.cluster.routing.allocation.RoutingExplanations; import org.elasticsearch.common.Strings; @@ -135,20 +135,20 @@ public static AllocationCommands fromXContent(XContentParser parser) throws IOEx XContentParser.Token token = parser.currentToken(); if (token == null) { - throw new ElasticsearchParseException("No commands"); + throw new OpenSearchParseException("No commands"); } if (token == XContentParser.Token.FIELD_NAME) { if (!parser.currentName().equals("commands")) { - throw new ElasticsearchParseException("expected field name to be named [commands], got [{}] instead", parser.currentName()); + throw new OpenSearchParseException("expected field name to be named [commands], got [{}] instead", parser.currentName()); } token = parser.nextToken(); if (token != XContentParser.Token.START_ARRAY) { - throw new ElasticsearchParseException("commands should follow with an array element"); + throw new OpenSearchParseException("commands should follow with an array element"); } } else if (token == XContentParser.Token.START_ARRAY) { // ok... } else { - throw new ElasticsearchParseException("expected either field name [commands], or start array, got [{}] instead", token); + throw new OpenSearchParseException("expected either field name [commands], or start array, got [{}] instead", token); } while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) { if (token == XContentParser.Token.START_OBJECT) { @@ -159,11 +159,11 @@ public static AllocationCommands fromXContent(XContentParser parser) throws IOEx commands.add(parser.namedObject(AllocationCommand.class, commandName, null)); // move to the end object one if (parser.nextToken() != XContentParser.Token.END_OBJECT) { - throw new ElasticsearchParseException("allocation command is malformed, done parsing a command," + + throw new OpenSearchParseException("allocation command is malformed, done parsing a command," + " but didn't get END_OBJECT, got [{}] instead", token); } } else { - throw new ElasticsearchParseException("allocation command is malformed, got [{}] instead", token); + throw new OpenSearchParseException("allocation command is malformed, got [{}] instead", token); } } return commands; diff --git a/server/src/main/java/org/elasticsearch/cluster/routing/allocation/command/CancelAllocationCommand.java b/server/src/main/java/org/elasticsearch/cluster/routing/allocation/command/CancelAllocationCommand.java index 3effbc83e9ca6..e52b84768d9fa 100644 --- a/server/src/main/java/org/elasticsearch/cluster/routing/allocation/command/CancelAllocationCommand.java +++ b/server/src/main/java/org/elasticsearch/cluster/routing/allocation/command/CancelAllocationCommand.java @@ -20,7 +20,7 @@ package org.elasticsearch.cluster.routing.allocation.command; import org.apache.logging.log4j.LogManager; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.routing.RoutingNode; @@ -193,20 +193,20 @@ public static CancelAllocationCommand fromXContent(XContentParser parser) throws } else if ("allow_primary".equals(currentFieldName) || "allowPrimary".equals(currentFieldName)) { allowPrimary = parser.booleanValue(); } else { - throw new ElasticsearchParseException("[{}] command does not support field [{}]", NAME, currentFieldName); + throw new OpenSearchParseException("[{}] command does not support field [{}]", NAME, currentFieldName); } } else { - throw new ElasticsearchParseException("[{}] command does not support complex json tokens [{}]", NAME, token); + throw new OpenSearchParseException("[{}] command does not support complex json tokens [{}]", NAME, token); } } if (index == null) { - throw new ElasticsearchParseException("[{}] command missing the index parameter", NAME); + throw new OpenSearchParseException("[{}] command missing the index parameter", NAME); } if (shardId == -1) { - throw new ElasticsearchParseException("[{}] command missing the shard parameter", NAME); + throw new OpenSearchParseException("[{}] command missing the shard parameter", NAME); } if (nodeId == null) { - throw new ElasticsearchParseException("[{}] command missing the node parameter", NAME); + throw new OpenSearchParseException("[{}] command missing the node parameter", NAME); } return new CancelAllocationCommand(index, shardId, nodeId, allowPrimary); } diff --git a/server/src/main/java/org/elasticsearch/cluster/routing/allocation/command/MoveAllocationCommand.java b/server/src/main/java/org/elasticsearch/cluster/routing/allocation/command/MoveAllocationCommand.java index 9358935542029..98f971d8618e7 100644 --- a/server/src/main/java/org/elasticsearch/cluster/routing/allocation/command/MoveAllocationCommand.java +++ b/server/src/main/java/org/elasticsearch/cluster/routing/allocation/command/MoveAllocationCommand.java @@ -19,7 +19,7 @@ package org.elasticsearch.cluster.routing.allocation.command; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.routing.RoutingNode; import org.elasticsearch.cluster.routing.ShardRouting; @@ -190,23 +190,23 @@ public static MoveAllocationCommand fromXContent(XContentParser parser) throws I } else if ("to_node".equals(currentFieldName) || "toNode".equals(currentFieldName)) { toNode = parser.text(); } else { - throw new ElasticsearchParseException("[{}] command does not support field [{}]", NAME, currentFieldName); + throw new OpenSearchParseException("[{}] command does not support field [{}]", NAME, currentFieldName); } } else { - throw new ElasticsearchParseException("[{}] command does not support complex json tokens [{}]", NAME, token); + throw new OpenSearchParseException("[{}] command does not support complex json tokens [{}]", NAME, token); } } if (index == null) { - throw new ElasticsearchParseException("[{}] command missing the index parameter", NAME); + throw new OpenSearchParseException("[{}] command missing the index parameter", NAME); } if (shardId == -1) { - throw new ElasticsearchParseException("[{}] command missing the shard parameter", NAME); + throw new OpenSearchParseException("[{}] command missing the shard parameter", NAME); } if (fromNode == null) { - throw new ElasticsearchParseException("[{}] command missing the from_node parameter", NAME); + throw new OpenSearchParseException("[{}] command missing the from_node parameter", NAME); } if (toNode == null) { - throw new ElasticsearchParseException("[{}] command missing the to_node parameter", NAME); + throw new OpenSearchParseException("[{}] command missing the to_node parameter", NAME); } return new MoveAllocationCommand(index, shardId, fromNode, toNode); } diff --git a/server/src/main/java/org/elasticsearch/common/geo/GeoBoundingBox.java b/server/src/main/java/org/elasticsearch/common/geo/GeoBoundingBox.java index 01315d3e9848c..02713e86281e1 100644 --- a/server/src/main/java/org/elasticsearch/common/geo/GeoBoundingBox.java +++ b/server/src/main/java/org/elasticsearch/common/geo/GeoBoundingBox.java @@ -18,7 +18,7 @@ */ package org.elasticsearch.common.geo; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.common.ParseField; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; @@ -173,10 +173,10 @@ public String toString() { /** * Parses the bounding box and returns bottom, top, left, right coordinates */ - public static GeoBoundingBox parseBoundingBox(XContentParser parser) throws IOException, ElasticsearchParseException { + public static GeoBoundingBox parseBoundingBox(XContentParser parser) throws IOException, OpenSearchParseException { XContentParser.Token token = parser.currentToken(); if (token != XContentParser.Token.START_OBJECT) { - throw new ElasticsearchParseException("failed to parse bounding box. Expected start object but found [{}]", token); + throw new OpenSearchParseException("failed to parse bounding box. Expected start object but found [{}]", token); } double top = Double.NaN; @@ -196,12 +196,12 @@ public static GeoBoundingBox parseBoundingBox(XContentParser parser) throws IOEx try { Geometry geometry = WKT_PARSER.fromWKT(parser.text()); if (ShapeType.ENVELOPE.equals(geometry.type()) == false) { - throw new ElasticsearchParseException("failed to parse WKT bounding box. [" + throw new OpenSearchParseException("failed to parse WKT bounding box. [" + geometry.type() + "] found. expected [" + ShapeType.ENVELOPE + "]"); } envelope = (Rectangle) geometry; } catch (ParseException|IllegalArgumentException e) { - throw new ElasticsearchParseException("failed to parse WKT bounding box", e); + throw new OpenSearchParseException("failed to parse WKT bounding box", e); } } else if (TOP_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { top = parser.doubleValue(); @@ -229,17 +229,17 @@ public static GeoBoundingBox parseBoundingBox(XContentParser parser) throws IOEx bottom = sparse.getLat(); left = sparse.getLon(); } else { - throw new ElasticsearchParseException("failed to parse bounding box. unexpected field [{}]", currentFieldName); + throw new OpenSearchParseException("failed to parse bounding box. unexpected field [{}]", currentFieldName); } } } else { - throw new ElasticsearchParseException("failed to parse bounding box. field name expected but [{}] found", token); + throw new OpenSearchParseException("failed to parse bounding box. field name expected but [{}] found", token); } } if (envelope != null) { if (Double.isNaN(top) == false || Double.isNaN(bottom) == false || Double.isNaN(left) == false || Double.isNaN(right) == false) { - throw new ElasticsearchParseException("failed to parse bounding box. Conflicting definition found " + throw new OpenSearchParseException("failed to parse bounding box. Conflicting definition found " + "using well-known text and explicit corners."); } GeoPoint topLeft = new GeoPoint(envelope.getMaxLat(), envelope.getMinLon()); diff --git a/server/src/main/java/org/elasticsearch/common/geo/GeoJson.java b/server/src/main/java/org/elasticsearch/common/geo/GeoJson.java index c4767106b58fc..0fa70cf76f3a4 100644 --- a/server/src/main/java/org/elasticsearch/common/geo/GeoJson.java +++ b/server/src/main/java/org/elasticsearch/common/geo/GeoJson.java @@ -20,7 +20,7 @@ package org.elasticsearch.common.geo; import org.elasticsearch.OpenSearchException; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.common.ParseField; import org.elasticsearch.common.geo.parsers.ShapeParser; import org.elasticsearch.common.unit.DistanceUnit; @@ -375,10 +375,10 @@ private static Geometry createGeometry(String type, List geometries, C } if (shapeType == ShapeType.GEOMETRYCOLLECTION) { if (geometries == null) { - throw new ElasticsearchParseException("geometries not included"); + throw new OpenSearchParseException("geometries not included"); } if (coordinates != null) { - throw new ElasticsearchParseException("parameter coordinates is not supported for type " + type); + throw new OpenSearchParseException("parameter coordinates is not supported for type " + type); } verifyNulls(type, null, orientation, radius); return new GeometryCollection<>(geometries); @@ -386,13 +386,13 @@ private static Geometry createGeometry(String type, List geometries, C // We expect to have coordinates for all the rest if (coordinates == null) { - throw new ElasticsearchParseException("coordinates not included"); + throw new OpenSearchParseException("coordinates not included"); } switch (shapeType) { case CIRCLE: if (radius == null) { - throw new ElasticsearchParseException("radius is not specified"); + throw new OpenSearchParseException("radius is not specified"); } verifyNulls(type, geometries, orientation, null); Point point = coordinates.asPoint(); @@ -421,7 +421,7 @@ private static Geometry createGeometry(String type, List geometries, C verifyNulls(type, geometries, orientation, radius); return coordinates.asRectangle(); default: - throw new ElasticsearchParseException("unsupported shape type " + type); + throw new OpenSearchParseException("unsupported shape type " + type); } } @@ -430,13 +430,13 @@ private static Geometry createGeometry(String type, List geometries, C */ private static void verifyNulls(String type, List geometries, Boolean orientation, DistanceUnit.Distance radius) { if (geometries != null) { - throw new ElasticsearchParseException("parameter geometries is not supported for type " + type); + throw new OpenSearchParseException("parameter geometries is not supported for type " + type); } if (orientation != null) { - throw new ElasticsearchParseException("parameter orientation is not supported for type " + type); + throw new OpenSearchParseException("parameter orientation is not supported for type " + type); } if (radius != null) { - throw new ElasticsearchParseException("parameter radius is not supported for type " + type); + throw new OpenSearchParseException("parameter radius is not supported for type " + type); } } @@ -459,7 +459,7 @@ private static CoordinateNode parseCoordinates(XContentParser parser) throws IOE while (token != XContentParser.Token.END_ARRAY) { CoordinateNode node = parseCoordinates(parser); if (nodes.isEmpty() == false && nodes.get(0).numDimensions() != node.numDimensions()) { - throw new ElasticsearchParseException("Exception parsing coordinates: number of dimensions do not match"); + throw new OpenSearchParseException("Exception parsing coordinates: number of dimensions do not match"); } nodes.add(node); token = parser.nextToken(); @@ -474,11 +474,11 @@ private static CoordinateNode parseCoordinates(XContentParser parser) throws IOE private static Point parseCoordinate(XContentParser parser) throws IOException { // Add support for coerce here if (parser.currentToken() != XContentParser.Token.VALUE_NUMBER) { - throw new ElasticsearchParseException("geo coordinates must be numbers"); + throw new OpenSearchParseException("geo coordinates must be numbers"); } double lon = parser.doubleValue(); if (parser.nextToken() != XContentParser.Token.VALUE_NUMBER) { - throw new ElasticsearchParseException("geo coordinates must be numbers"); + throw new OpenSearchParseException("geo coordinates must be numbers"); } double lat = parser.doubleValue(); XContentParser.Token token = parser.nextToken(); @@ -490,7 +490,7 @@ private static Point parseCoordinate(XContentParser parser) throws IOException { } // do not support > 3 dimensions if (parser.currentToken() == XContentParser.Token.VALUE_NUMBER) { - throw new ElasticsearchParseException("geo coordinates greater than 3 dimensions are not supported"); + throw new OpenSearchParseException("geo coordinates greater than 3 dimensions are not supported"); } return new Point(lon, lat, alt); } @@ -724,7 +724,7 @@ public MultiPolygon asMultiPolygon(boolean orientation, boolean coerce) { public Rectangle asRectangle() { if (children.size() != 2) { - throw new ElasticsearchParseException( + throw new OpenSearchParseException( "invalid number of points [{}] provided for geo_shape [{}] when expecting an array of 2 coordinates", children.size(), ShapeType.ENVELOPE); } diff --git a/server/src/main/java/org/elasticsearch/common/geo/GeoPoint.java b/server/src/main/java/org/elasticsearch/common/geo/GeoPoint.java index c93ff12a450b2..daa3c0414ea27 100644 --- a/server/src/main/java/org/elasticsearch/common/geo/GeoPoint.java +++ b/server/src/main/java/org/elasticsearch/common/geo/GeoPoint.java @@ -25,10 +25,10 @@ import org.apache.lucene.index.IndexableField; import org.apache.lucene.util.BitUtil; import org.apache.lucene.util.BytesRef; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.common.geo.GeoUtils.EffectivePoint; import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.common.xcontent.XContentBuilder; -import org.elasticsearch.ElasticsearchParseException; import org.elasticsearch.geometry.Geometry; import org.elasticsearch.geometry.Point; import org.elasticsearch.geometry.Rectangle; @@ -103,7 +103,7 @@ public GeoPoint resetFromString(String value, final boolean ignoreZValue, Effect public GeoPoint resetFromCoordinates(String value, final boolean ignoreZValue) { String[] vals = value.split(","); if (vals.length > 3) { - throw new ElasticsearchParseException("failed to parse [{}], expected 2 or 3 coordinates " + throw new OpenSearchParseException("failed to parse [{}], expected 2 or 3 coordinates " + "but found: [{}]", vals.length); } final double lat; @@ -111,12 +111,12 @@ public GeoPoint resetFromCoordinates(String value, final boolean ignoreZValue) { try { lat = Double.parseDouble(vals[0].trim()); } catch (NumberFormatException ex) { - throw new ElasticsearchParseException("latitude must be a number"); + throw new OpenSearchParseException("latitude must be a number"); } try { lon = Double.parseDouble(vals[1].trim()); } catch (NumberFormatException ex) { - throw new ElasticsearchParseException("longitude must be a number"); + throw new OpenSearchParseException("longitude must be a number"); } if (vals.length > 2) { GeoPoint.assertZValue(ignoreZValue, Double.parseDouble(vals[2].trim())); @@ -130,10 +130,10 @@ private GeoPoint resetFromWKT(String value, boolean ignoreZValue) { geometry = new WellKnownText(false, new GeographyValidator(ignoreZValue)) .fromWKT(value); } catch (Exception e) { - throw new ElasticsearchParseException("Invalid WKT format", e); + throw new OpenSearchParseException("Invalid WKT format", e); } if (geometry.type() != ShapeType.POINT) { - throw new ElasticsearchParseException("[geo_point] supports only POINT among WKT primitives, " + + throw new OpenSearchParseException("[geo_point] supports only POINT among WKT primitives, " + "but found " + geometry.type()); } Point point = (Point) geometry; @@ -187,7 +187,7 @@ public GeoPoint resetFromGeoHash(String geohash) { try { hash = Geohash.mortonEncode(geohash); } catch (IllegalArgumentException ex) { - throw new ElasticsearchParseException(ex.getMessage(), ex); + throw new OpenSearchParseException(ex.getMessage(), ex); } return this.reset(Geohash.decodeLatitude(hash), Geohash.decodeLongitude(hash)); } @@ -265,7 +265,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws public static double assertZValue(final boolean ignoreZValue, double zValue) { if (ignoreZValue == false) { - throw new ElasticsearchParseException("Exception parsing coordinates: found Z value [{}] but [{}] " + throw new OpenSearchParseException("Exception parsing coordinates: found Z value [{}] but [{}] " + "parameter is [{}]", zValue, IGNORE_Z_VALUE, ignoreZValue); } return zValue; diff --git a/server/src/main/java/org/elasticsearch/common/geo/GeoShapeType.java b/server/src/main/java/org/elasticsearch/common/geo/GeoShapeType.java index 7246e26f8cbc1..dc9893266c955 100644 --- a/server/src/main/java/org/elasticsearch/common/geo/GeoShapeType.java +++ b/server/src/main/java/org/elasticsearch/common/geo/GeoShapeType.java @@ -18,7 +18,7 @@ */ package org.elasticsearch.common.geo; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.common.geo.builders.CircleBuilder; import org.elasticsearch.common.geo.builders.CoordinatesBuilder; import org.elasticsearch.common.geo.builders.EnvelopeBuilder; @@ -56,10 +56,10 @@ public PointBuilder getBuilder(CoordinateNode coordinates, DistanceUnit.Distance @Override CoordinateNode validate(CoordinateNode coordinates, boolean coerce) { if (coordinates.isEmpty()) { - throw new ElasticsearchParseException( + throw new OpenSearchParseException( "invalid number of points (0) provided when expecting a single coordinate ([lat, lng])"); } else if (coordinates.children != null) { - throw new ElasticsearchParseException("multipoint data provided when single point data expected."); + throw new OpenSearchParseException("multipoint data provided when single point data expected."); } return coordinates; } @@ -80,10 +80,10 @@ public MultiPointBuilder getBuilder(CoordinateNode coordinates, DistanceUnit.Dis CoordinateNode validate(CoordinateNode coordinates, boolean coerce) { if (coordinates.children == null || coordinates.children.isEmpty()) { if (coordinates.coordinate != null) { - throw new ElasticsearchParseException("single coordinate found when expecting an array of " + + throw new OpenSearchParseException("single coordinate found when expecting an array of " + "coordinates. change type to point or change data to an array of >0 coordinates"); } - throw new ElasticsearchParseException("no data provided for multipoint object when expecting " + + throw new OpenSearchParseException("no data provided for multipoint object when expecting " + ">0 points (e.g., [[lat, lng]] or [[lat, lng], ...])"); } else { for (CoordinateNode point : coordinates.children) { @@ -109,7 +109,7 @@ public LineStringBuilder getBuilder(CoordinateNode coordinates, DistanceUnit.Dis @Override CoordinateNode validate(CoordinateNode coordinates, boolean coerce) { if (coordinates.children.size() < 2) { - throw new ElasticsearchParseException("invalid number of points in LineString (found [{}] - must be >= 2)", + throw new OpenSearchParseException("invalid number of points in LineString (found [{}] - must be >= 2)", coordinates.children.size()); } return coordinates; @@ -130,7 +130,7 @@ public MultiLineStringBuilder getBuilder(CoordinateNode coordinates, DistanceUni @Override CoordinateNode validate(CoordinateNode coordinates, boolean coerce) { if (coordinates.children.size() < 1) { - throw new ElasticsearchParseException("invalid number of lines in MultiLineString (found [{}] - must be >= 1)", + throw new OpenSearchParseException("invalid number of lines in MultiLineString (found [{}] - must be >= 1)", coordinates.children.size()); } return coordinates; @@ -159,12 +159,12 @@ void validateLinearRing(CoordinateNode coordinates, boolean coerce) { String error = "Invalid LinearRing found."; error += (coordinates.coordinate == null) ? " No coordinate array provided" : " Found a single coordinate when expecting a coordinate array"; - throw new ElasticsearchParseException(error); + throw new OpenSearchParseException(error); } int numValidPts = coerce ? 3 : 4; if (coordinates.children.size() < numValidPts) { - throw new ElasticsearchParseException("invalid number of points in LinearRing (found [{}] - must be >= [{}])", + throw new OpenSearchParseException("invalid number of points in LinearRing (found [{}] - must be >= [{}])", coordinates.children.size(), numValidPts); } // close linear ring iff coerce is set and ring is open, otherwise throw parse exception @@ -173,7 +173,7 @@ void validateLinearRing(CoordinateNode coordinates, boolean coerce) { if (coerce) { coordinates.children.add(coordinates.children.get(0)); } else { - throw new ElasticsearchParseException("invalid LinearRing found (coordinates are not closed)"); + throw new OpenSearchParseException("invalid LinearRing found (coordinates are not closed)"); } } } @@ -187,7 +187,7 @@ CoordinateNode validate(CoordinateNode coordinates, boolean coerce) { * represented as a GeoJSON geometry type, it is referred to in the Polygon geometry type definition. */ if (coordinates.children == null || coordinates.children.isEmpty()) { - throw new ElasticsearchParseException( + throw new OpenSearchParseException( "invalid LinearRing provided for type polygon. Linear ring must be an array of coordinates"); } for (CoordinateNode ring : coordinates.children) { @@ -230,7 +230,7 @@ public EnvelopeBuilder getBuilder(CoordinateNode coordinates, DistanceUnit.Dista CoordinateNode validate(CoordinateNode coordinates, boolean coerce) { // validate the coordinate array for envelope type if (coordinates.children.size() != 2) { - throw new ElasticsearchParseException( + throw new OpenSearchParseException( "invalid number of points [{}] provided for geo_shape [{}] when expecting an array of 2 coordinates", coordinates.children.size(), GeoShapeType.ENVELOPE.shapename); } diff --git a/server/src/main/java/org/elasticsearch/common/geo/GeoUtils.java b/server/src/main/java/org/elasticsearch/common/geo/GeoUtils.java index b4f450421c5de..cfe70dc2ecd27 100644 --- a/server/src/main/java/org/elasticsearch/common/geo/GeoUtils.java +++ b/server/src/main/java/org/elasticsearch/common/geo/GeoUtils.java @@ -22,7 +22,7 @@ import org.apache.lucene.spatial.prefix.tree.GeohashPrefixTree; import org.apache.lucene.spatial.prefix.tree.QuadPrefixTree; import org.apache.lucene.util.SloppyMath; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.common.unit.DistanceUnit; import org.elasticsearch.common.xcontent.LoggingDeprecationHandler; import org.elasticsearch.common.xcontent.NamedXContentRegistry; @@ -354,12 +354,12 @@ public static double centeredModulus(double dividend, double divisor) { * @param parser {@link XContentParser} to parse the value from * @return new {@link GeoPoint} parsed from the parse */ - public static GeoPoint parseGeoPoint(XContentParser parser) throws IOException, ElasticsearchParseException { + public static GeoPoint parseGeoPoint(XContentParser parser) throws IOException, OpenSearchParseException { return parseGeoPoint(parser, new GeoPoint()); } - public static GeoPoint parseGeoPoint(XContentParser parser, GeoPoint point) throws IOException, ElasticsearchParseException { + public static GeoPoint parseGeoPoint(XContentParser parser, GeoPoint point) throws IOException, OpenSearchParseException { return parseGeoPoint(parser, point, false); } @@ -372,7 +372,7 @@ public static GeoPoint parseGeoPoint(XContentParser parser, GeoPoint point) thro *

* Array: two or more elements, the first element is longitude, the second is latitude, the rest is ignored if ignoreZValue is true */ - public static GeoPoint parseGeoPoint(Object value, final boolean ignoreZValue) throws ElasticsearchParseException { + public static GeoPoint parseGeoPoint(Object value, final boolean ignoreZValue) throws OpenSearchParseException { return parseGeoPoint(value, new GeoPoint(), ignoreZValue); } @@ -385,7 +385,7 @@ public static GeoPoint parseGeoPoint(Object value, final boolean ignoreZValue) t *

* Array: two or more elements, the first element is longitude, the second is latitude, the rest is ignored if ignoreZValue is true */ - public static GeoPoint parseGeoPoint(Object value, GeoPoint point, final boolean ignoreZValue) throws ElasticsearchParseException { + public static GeoPoint parseGeoPoint(Object value, GeoPoint point, final boolean ignoreZValue) throws OpenSearchParseException { try (XContentParser parser = new MapXContentParser(NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, Collections.singletonMap("null_value", value), null)) { parser.nextToken(); // start object @@ -393,7 +393,7 @@ public static GeoPoint parseGeoPoint(Object value, GeoPoint point, final boolean parser.nextToken(); // field value return parseGeoPoint(parser, point, ignoreZValue); } catch (IOException ex) { - throw new ElasticsearchParseException("error parsing geopoint", ex); + throw new OpenSearchParseException("error parsing geopoint", ex); } } @@ -412,7 +412,7 @@ public enum EffectivePoint { * the left bottom corner of the geohash cell is used as the geopoint coordinates.GeoBoundingBoxQueryBuilder.java */ public static GeoPoint parseGeoPoint(XContentParser parser, GeoPoint point, final boolean ignoreZValue) - throws IOException, ElasticsearchParseException { + throws IOException, OpenSearchParseException { return parseGeoPoint(parser, point, ignoreZValue, EffectivePoint.BOTTOM_LEFT); } @@ -431,7 +431,7 @@ public static GeoPoint parseGeoPoint(XContentParser parser, GeoPoint point, fina * @return new {@link GeoPoint} parsed from the parse */ public static GeoPoint parseGeoPoint(XContentParser parser, GeoPoint point, final boolean ignoreZValue, EffectivePoint effectivePoint) - throws IOException, ElasticsearchParseException { + throws IOException, OpenSearchParseException { double lat = Double.NaN; double lon = Double.NaN; String geohash = null; @@ -454,7 +454,7 @@ public static GeoPoint parseGeoPoint(XContentParser parser, GeoPoint point, fina } break; default: - throw new ElasticsearchParseException("latitude must be a number"); + throw new OpenSearchParseException("latitude must be a number"); } } else if (LONGITUDE.equals(field)) { subParser.nextToken(); @@ -468,35 +468,35 @@ public static GeoPoint parseGeoPoint(XContentParser parser, GeoPoint point, fina } break; default: - throw new ElasticsearchParseException("longitude must be a number"); + throw new OpenSearchParseException("longitude must be a number"); } } else if (GEOHASH.equals(field)) { if (subParser.nextToken() == Token.VALUE_STRING) { geohash = subParser.text(); } else { - throw new ElasticsearchParseException("geohash must be a string"); + throw new OpenSearchParseException("geohash must be a string"); } } else { - throw new ElasticsearchParseException("field must be either [{}], [{}] or [{}]", LATITUDE, LONGITUDE, GEOHASH); + throw new OpenSearchParseException("field must be either [{}], [{}] or [{}]", LATITUDE, LONGITUDE, GEOHASH); } } else { - throw new ElasticsearchParseException("token [{}] not allowed", subParser.currentToken()); + throw new OpenSearchParseException("token [{}] not allowed", subParser.currentToken()); } } } if (geohash != null) { if(!Double.isNaN(lat) || !Double.isNaN(lon)) { - throw new ElasticsearchParseException("field must be either lat/lon or geohash"); + throw new OpenSearchParseException("field must be either lat/lon or geohash"); } else { return point.parseGeoHash(geohash, effectivePoint); } } else if (numberFormatException != null) { - throw new ElasticsearchParseException("[{}] and [{}] must be valid double values", numberFormatException, LATITUDE, + throw new OpenSearchParseException("[{}] and [{}] must be valid double values", numberFormatException, LATITUDE, LONGITUDE); } else if (Double.isNaN(lat)) { - throw new ElasticsearchParseException("field [{}] missing", LATITUDE); + throw new OpenSearchParseException("field [{}] missing", LATITUDE); } else if (Double.isNaN(lon)) { - throw new ElasticsearchParseException("field [{}] missing", LONGITUDE); + throw new OpenSearchParseException("field [{}] missing", LONGITUDE); } else { return point.reset(lat, lon); } @@ -514,10 +514,10 @@ public static GeoPoint parseGeoPoint(XContentParser parser, GeoPoint point, fina } else if (element == 3) { GeoPoint.assertZValue(ignoreZValue, subParser.doubleValue()); } else { - throw new ElasticsearchParseException("[geo_point] field type does not accept > 3 dimensions"); + throw new OpenSearchParseException("[geo_point] field type does not accept > 3 dimensions"); } } else { - throw new ElasticsearchParseException("numeric value expected"); + throw new OpenSearchParseException("numeric value expected"); } } } @@ -526,7 +526,7 @@ public static GeoPoint parseGeoPoint(XContentParser parser, GeoPoint point, fina String val = parser.text(); return point.resetFromString(val, ignoreZValue, effectivePoint); } else { - throw new ElasticsearchParseException("geo_point expected"); + throw new OpenSearchParseException("geo_point expected"); } } @@ -555,7 +555,7 @@ public static GeoPoint parseFromString(String val) { * @param parser {@link XContentParser} to parse the value from * @return int representing precision */ - public static int parsePrecision(XContentParser parser) throws IOException, ElasticsearchParseException { + public static int parsePrecision(XContentParser parser) throws IOException, OpenSearchParseException { XContentParser.Token token = parser.currentToken(); if (token.equals(XContentParser.Token.VALUE_NUMBER)) { return XContentMapValues.nodeIntegerValue(parser.intValue()); diff --git a/server/src/main/java/org/elasticsearch/common/geo/GeometryParser.java b/server/src/main/java/org/elasticsearch/common/geo/GeometryParser.java index ce684fd72cbd3..81e073a479e4e 100644 --- a/server/src/main/java/org/elasticsearch/common/geo/GeometryParser.java +++ b/server/src/main/java/org/elasticsearch/common/geo/GeometryParser.java @@ -19,7 +19,7 @@ package org.elasticsearch.common.geo; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.common.xcontent.LoggingDeprecationHandler; import org.elasticsearch.common.xcontent.NamedXContentRegistry; import org.elasticsearch.common.xcontent.XContentParser; @@ -87,7 +87,7 @@ public GeometryFormat geometryFormat(XContentParser parser) { // We don't know the format of the original geometry - so going with default return new GeoJsonGeometryFormat(geoJsonParser); } else { - throw new ElasticsearchParseException("shape must be an object consisting of type and coordinates"); + throw new OpenSearchParseException("shape must be an object consisting of type and coordinates"); } } @@ -102,7 +102,7 @@ public GeometryFormat geometryFormat(XContentParser parser) { *

* Json structure: valid geojson definition */ - public Geometry parseGeometry(Object value) throws ElasticsearchParseException { + public Geometry parseGeometry(Object value) throws OpenSearchParseException { if (value instanceof List) { List values = (List) value; if (values.size() == 2 && values.get(0) instanceof Number) { @@ -129,7 +129,7 @@ public Geometry parseGeometry(Object value) throws ElasticsearchParseException } } catch (IOException | ParseException ex) { - throw new ElasticsearchParseException("error parsing geometry ", ex); + throw new OpenSearchParseException("error parsing geometry ", ex); } } diff --git a/server/src/main/java/org/elasticsearch/common/geo/parsers/GeoJsonParser.java b/server/src/main/java/org/elasticsearch/common/geo/parsers/GeoJsonParser.java index 299e07cb35057..2614a31dec8fb 100644 --- a/server/src/main/java/org/elasticsearch/common/geo/parsers/GeoJsonParser.java +++ b/server/src/main/java/org/elasticsearch/common/geo/parsers/GeoJsonParser.java @@ -18,7 +18,7 @@ */ package org.elasticsearch.common.geo.parsers; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.common.Explicit; import org.elasticsearch.common.geo.GeoPoint; import org.elasticsearch.common.geo.GeoShapeType; @@ -80,7 +80,7 @@ protected static ShapeBuilder parse(XContentParser parser, AbstractShapeGeometry subParser.nextToken(); CoordinateNode tempNode = parseCoordinates(subParser, ignoreZValue.value()); if (coordinateNode != null && tempNode.numDimensions() != coordinateNode.numDimensions()) { - throw new ElasticsearchParseException("Exception parsing coordinates: " + + throw new OpenSearchParseException("Exception parsing coordinates: " + "number of dimensions do not match"); } coordinateNode = tempNode; @@ -118,15 +118,15 @@ protected static ShapeBuilder parse(XContentParser parser, AbstractShapeGeometry } if (malformedException != null) { - throw new ElasticsearchParseException(malformedException); + throw new OpenSearchParseException(malformedException); } else if (shapeType == null) { - throw new ElasticsearchParseException("shape type not included"); + throw new OpenSearchParseException("shape type not included"); } else if (coordinateNode == null && GeoShapeType.GEOMETRYCOLLECTION != shapeType) { - throw new ElasticsearchParseException("coordinates not included"); + throw new OpenSearchParseException("coordinates not included"); } else if (geometryCollections == null && GeoShapeType.GEOMETRYCOLLECTION == shapeType) { - throw new ElasticsearchParseException("geometries not included"); + throw new OpenSearchParseException("geometries not included"); } else if (radius != null && GeoShapeType.CIRCLE != shapeType) { - throw new ElasticsearchParseException("field [{}] is supported for [{}] only", CircleBuilder.FIELD_RADIUS, + throw new OpenSearchParseException("field [{}] is supported for [{}] only", CircleBuilder.FIELD_RADIUS, CircleBuilder.TYPE); } @@ -152,7 +152,7 @@ private static CoordinateNode parseCoordinates(XContentParser parser, boolean ig if (parser.currentToken() == XContentParser.Token.START_OBJECT) { parser.skipChildren(); parser.nextToken(); - throw new ElasticsearchParseException("coordinates cannot be specified as objects"); + throw new OpenSearchParseException("coordinates cannot be specified as objects"); } XContentParser.Token token = parser.nextToken(); @@ -169,7 +169,7 @@ private static CoordinateNode parseCoordinates(XContentParser parser, boolean ig while (token != XContentParser.Token.END_ARRAY) { CoordinateNode node = parseCoordinates(parser, ignoreZValue); if (nodes.isEmpty() == false && nodes.get(0).numDimensions() != node.numDimensions()) { - throw new ElasticsearchParseException("Exception parsing coordinates: number of dimensions do not match"); + throw new OpenSearchParseException("Exception parsing coordinates: number of dimensions do not match"); } nodes.add(node); token = parser.nextToken(); @@ -180,11 +180,11 @@ private static CoordinateNode parseCoordinates(XContentParser parser, boolean ig private static Coordinate parseCoordinate(XContentParser parser, boolean ignoreZValue) throws IOException { if (parser.currentToken() != XContentParser.Token.VALUE_NUMBER) { - throw new ElasticsearchParseException("geo coordinates must be numbers"); + throw new OpenSearchParseException("geo coordinates must be numbers"); } double lon = parser.doubleValue(); if (parser.nextToken() != XContentParser.Token.VALUE_NUMBER) { - throw new ElasticsearchParseException("geo coordinates must be numbers"); + throw new OpenSearchParseException("geo coordinates must be numbers"); } double lat = parser.doubleValue(); XContentParser.Token token = parser.nextToken(); @@ -196,7 +196,7 @@ private static Coordinate parseCoordinate(XContentParser parser, boolean ignoreZ } // do not support > 3 dimensions if (parser.currentToken() == XContentParser.Token.VALUE_NUMBER) { - throw new ElasticsearchParseException("geo coordinates greater than 3 dimensions are not supported"); + throw new OpenSearchParseException("geo coordinates greater than 3 dimensions are not supported"); } return new Coordinate(lon, lat, alt); } @@ -211,7 +211,7 @@ private static Coordinate parseCoordinate(XContentParser parser, boolean ignoreZ static GeometryCollectionBuilder parseGeometries(XContentParser parser, AbstractShapeGeometryFieldMapper mapper) throws IOException { if (parser.currentToken() != XContentParser.Token.START_ARRAY) { - throw new ElasticsearchParseException("geometries must be an array of geojson objects"); + throw new OpenSearchParseException("geometries must be an array of geojson objects"); } XContentParser.Token token = parser.nextToken(); diff --git a/server/src/main/java/org/elasticsearch/common/geo/parsers/GeoWKTParser.java b/server/src/main/java/org/elasticsearch/common/geo/parsers/GeoWKTParser.java index 052ccb2afc58b..282accd699d7f 100644 --- a/server/src/main/java/org/elasticsearch/common/geo/parsers/GeoWKTParser.java +++ b/server/src/main/java/org/elasticsearch/common/geo/parsers/GeoWKTParser.java @@ -18,7 +18,7 @@ */ package org.elasticsearch.common.geo.parsers; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.common.Explicit; import org.elasticsearch.common.geo.GeoPoint; import org.elasticsearch.common.geo.GeoShapeType; @@ -64,19 +64,19 @@ public class GeoWKTParser { private GeoWKTParser() {} public static ShapeBuilder parse(XContentParser parser, final AbstractShapeGeometryFieldMapper shapeMapper) - throws IOException, ElasticsearchParseException { + throws IOException, OpenSearchParseException { return parseExpectedType(parser, null, shapeMapper); } public static ShapeBuilder parseExpectedType(XContentParser parser, final GeoShapeType shapeType) - throws IOException, ElasticsearchParseException { + throws IOException, OpenSearchParseException { return parseExpectedType(parser, shapeType, null); } /** throws an exception if the parsed geometry type does not match the expected shape type */ public static ShapeBuilder parseExpectedType(XContentParser parser, final GeoShapeType shapeType, final AbstractShapeGeometryFieldMapper shapeMapper) - throws IOException, ElasticsearchParseException { + throws IOException, OpenSearchParseException { try (StringReader reader = new StringReader(parser.text())) { Explicit ignoreZValue = (shapeMapper == null) ? AbstractShapeGeometryFieldMapper.Defaults.IGNORE_Z_VALUE : shapeMapper.ignoreZValue(); @@ -102,11 +102,11 @@ public static ShapeBuilder parseExpectedType(XContentParser parser, final GeoSha /** parse geometry from the stream tokenizer */ private static ShapeBuilder parseGeometry(StreamTokenizer stream, GeoShapeType shapeType, final boolean ignoreZValue, final boolean coerce) - throws IOException, ElasticsearchParseException { + throws IOException, OpenSearchParseException { final GeoShapeType type = GeoShapeType.forName(nextWord(stream)); if (shapeType != null && shapeType != GeoShapeType.GEOMETRYCOLLECTION) { if (type.wktName().equals(shapeType.wktName()) == false) { - throw new ElasticsearchParseException("Expected geometry type [{}] but found [{}]", shapeType, type); + throw new OpenSearchParseException("Expected geometry type [{}] but found [{}]", shapeType, type); } } switch (type) { @@ -131,7 +131,7 @@ private static ShapeBuilder parseGeometry(StreamTokenizer stream, GeoShapeType s } } - private static EnvelopeBuilder parseBBox(StreamTokenizer stream) throws IOException, ElasticsearchParseException { + private static EnvelopeBuilder parseBBox(StreamTokenizer stream) throws IOException, OpenSearchParseException { if (nextEmptyOrOpen(stream).equals(EMPTY)) { return null; } @@ -147,7 +147,7 @@ private static EnvelopeBuilder parseBBox(StreamTokenizer stream) throws IOExcept } private static PointBuilder parsePoint(StreamTokenizer stream, final boolean ignoreZValue, final boolean coerce) - throws IOException, ElasticsearchParseException { + throws IOException, OpenSearchParseException { if (nextEmptyOrOpen(stream).equals(EMPTY)) { return null; } @@ -160,7 +160,7 @@ private static PointBuilder parsePoint(StreamTokenizer stream, final boolean ign } private static List parseCoordinateList(StreamTokenizer stream, final boolean ignoreZValue, final boolean coerce) - throws IOException, ElasticsearchParseException { + throws IOException, OpenSearchParseException { CoordinatesBuilder coordinates = new CoordinatesBuilder(); boolean isOpenParen = false; if (isNumberNext(stream) || (isOpenParen = nextWord(stream).equals(LPAREN))) { @@ -168,7 +168,7 @@ private static List parseCoordinateList(StreamTokenizer stream, fina } if (isOpenParen && nextCloser(stream).equals(RPAREN) == false) { - throw new ElasticsearchParseException("expected: [{}]" + RPAREN + " but found: [{}]" + tokenString(stream), stream.lineno()); + throw new OpenSearchParseException("expected: [{}]" + RPAREN + " but found: [{}]" + tokenString(stream), stream.lineno()); } while (nextCloserOrComma(stream).equals(COMMA)) { @@ -177,14 +177,14 @@ private static List parseCoordinateList(StreamTokenizer stream, fina coordinates.coordinate(parseCoordinate(stream, ignoreZValue, coerce)); } if (isOpenParen && nextCloser(stream).equals(RPAREN) == false) { - throw new ElasticsearchParseException("expected: " + RPAREN + " but found: " + tokenString(stream), stream.lineno()); + throw new OpenSearchParseException("expected: " + RPAREN + " but found: " + tokenString(stream), stream.lineno()); } } return coordinates.build(); } private static Coordinate parseCoordinate(StreamTokenizer stream, final boolean ignoreZValue, final boolean coerce) - throws IOException, ElasticsearchParseException { + throws IOException, OpenSearchParseException { final double lon = nextNumber(stream); final double lat = nextNumber(stream); Double z = null; @@ -195,7 +195,7 @@ private static Coordinate parseCoordinate(StreamTokenizer stream, final boolean } private static MultiPointBuilder parseMultiPoint(StreamTokenizer stream, final boolean ignoreZValue, final boolean coerce) - throws IOException, ElasticsearchParseException { + throws IOException, OpenSearchParseException { String token = nextEmptyOrOpen(stream); if (token.equals(EMPTY)) { return new MultiPointBuilder(); @@ -204,7 +204,7 @@ private static MultiPointBuilder parseMultiPoint(StreamTokenizer stream, final b } private static LineStringBuilder parseLine(StreamTokenizer stream, final boolean ignoreZValue, final boolean coerce) - throws IOException, ElasticsearchParseException { + throws IOException, OpenSearchParseException { String token = nextEmptyOrOpen(stream); if (token.equals(EMPTY)) { return null; @@ -215,7 +215,7 @@ private static LineStringBuilder parseLine(StreamTokenizer stream, final boolean // A LinearRing is closed LineString with 4 or more positions. The first and last positions // are equivalent (they represent equivalent points). private static LineStringBuilder parseLinearRing(StreamTokenizer stream, final boolean ignoreZValue, final boolean coerce) - throws IOException, ElasticsearchParseException { + throws IOException, OpenSearchParseException { String token = nextEmptyOrOpen(stream); if (token.equals(EMPTY)) { return null; @@ -227,19 +227,19 @@ private static LineStringBuilder parseLinearRing(StreamTokenizer stream, final b if (coerce) { coordinates.add(coordinates.get(0)); } else { - throw new ElasticsearchParseException("invalid LinearRing found (coordinates are not closed)"); + throw new OpenSearchParseException("invalid LinearRing found (coordinates are not closed)"); } } } if (coordinates.size() < 4) { - throw new ElasticsearchParseException("invalid number of points in LinearRing (found [{}] - must be >= 4)", + throw new OpenSearchParseException("invalid number of points in LinearRing (found [{}] - must be >= 4)", coordinates.size()); } return new LineStringBuilder(coordinates); } private static MultiLineStringBuilder parseMultiLine(StreamTokenizer stream, final boolean ignoreZValue, final boolean coerce) - throws IOException, ElasticsearchParseException { + throws IOException, OpenSearchParseException { String token = nextEmptyOrOpen(stream); if (token.equals(EMPTY)) { return new MultiLineStringBuilder(); @@ -253,7 +253,7 @@ private static MultiLineStringBuilder parseMultiLine(StreamTokenizer stream, fin } private static PolygonBuilder parsePolygon(StreamTokenizer stream, final boolean ignoreZValue, final boolean coerce) - throws IOException, ElasticsearchParseException { + throws IOException, OpenSearchParseException { if (nextEmptyOrOpen(stream).equals(EMPTY)) { return null; } @@ -266,7 +266,7 @@ private static PolygonBuilder parsePolygon(StreamTokenizer stream, final boolean } private static MultiPolygonBuilder parseMultiPolygon(StreamTokenizer stream, final boolean ignoreZValue, final boolean coerce) - throws IOException, ElasticsearchParseException { + throws IOException, OpenSearchParseException { if (nextEmptyOrOpen(stream).equals(EMPTY)) { return null; } @@ -279,7 +279,7 @@ private static MultiPolygonBuilder parseMultiPolygon(StreamTokenizer stream, fin private static GeometryCollectionBuilder parseGeometryCollection(StreamTokenizer stream, final boolean ignoreZValue, final boolean coerce) - throws IOException, ElasticsearchParseException { + throws IOException, OpenSearchParseException { if (nextEmptyOrOpen(stream).equals(EMPTY)) { return null; } @@ -292,7 +292,7 @@ private static GeometryCollectionBuilder parseGeometryCollection(StreamTokenizer } /** next word in the stream */ - private static String nextWord(StreamTokenizer stream) throws ElasticsearchParseException, IOException { + private static String nextWord(StreamTokenizer stream) throws OpenSearchParseException, IOException { switch (stream.nextToken()) { case StreamTokenizer.TT_WORD: final String word = stream.sval; @@ -301,10 +301,10 @@ private static String nextWord(StreamTokenizer stream) throws ElasticsearchParse case ')': return RPAREN; case ',': return COMMA; } - throw new ElasticsearchParseException("expected word but found: " + tokenString(stream), stream.lineno()); + throw new OpenSearchParseException("expected word but found: " + tokenString(stream), stream.lineno()); } - private static double nextNumber(StreamTokenizer stream) throws IOException, ElasticsearchParseException { + private static double nextNumber(StreamTokenizer stream) throws IOException, OpenSearchParseException { if (stream.nextToken() == StreamTokenizer.TT_WORD) { if (stream.sval.equalsIgnoreCase(NAN)) { return Double.NaN; @@ -312,11 +312,11 @@ private static double nextNumber(StreamTokenizer stream) throws IOException, Ela try { return Double.parseDouble(stream.sval); } catch (NumberFormatException e) { - throw new ElasticsearchParseException("invalid number found: " + stream.sval, stream.lineno()); + throw new OpenSearchParseException("invalid number found: " + stream.sval, stream.lineno()); } } } - throw new ElasticsearchParseException("expected number but found: " + tokenString(stream), stream.lineno()); + throw new OpenSearchParseException("expected number but found: " + tokenString(stream), stream.lineno()); } private static String tokenString(StreamTokenizer stream) { @@ -335,42 +335,42 @@ private static boolean isNumberNext(StreamTokenizer stream) throws IOException { return type == StreamTokenizer.TT_WORD; } - private static String nextEmptyOrOpen(StreamTokenizer stream) throws IOException, ElasticsearchParseException { + private static String nextEmptyOrOpen(StreamTokenizer stream) throws IOException, OpenSearchParseException { final String next = nextWord(stream); if (next.equals(EMPTY) || next.equals(LPAREN)) { return next; } - throw new ElasticsearchParseException("expected " + EMPTY + " or " + LPAREN + throw new OpenSearchParseException("expected " + EMPTY + " or " + LPAREN + " but found: " + tokenString(stream), stream.lineno()); } - private static String nextCloser(StreamTokenizer stream) throws IOException, ElasticsearchParseException { + private static String nextCloser(StreamTokenizer stream) throws IOException, OpenSearchParseException { if (nextWord(stream).equals(RPAREN)) { return RPAREN; } - throw new ElasticsearchParseException("expected " + RPAREN + " but found: " + tokenString(stream), stream.lineno()); + throw new OpenSearchParseException("expected " + RPAREN + " but found: " + tokenString(stream), stream.lineno()); } - private static String nextComma(StreamTokenizer stream) throws IOException, ElasticsearchParseException { + private static String nextComma(StreamTokenizer stream) throws IOException, OpenSearchParseException { if (nextWord(stream).equals(COMMA)) { return COMMA; } - throw new ElasticsearchParseException("expected " + COMMA + " but found: " + tokenString(stream), stream.lineno()); + throw new OpenSearchParseException("expected " + COMMA + " but found: " + tokenString(stream), stream.lineno()); } - private static String nextCloserOrComma(StreamTokenizer stream) throws IOException, ElasticsearchParseException { + private static String nextCloserOrComma(StreamTokenizer stream) throws IOException, OpenSearchParseException { String token = nextWord(stream); if (token.equals(COMMA) || token.equals(RPAREN)) { return token; } - throw new ElasticsearchParseException("expected " + COMMA + " or " + RPAREN + throw new OpenSearchParseException("expected " + COMMA + " or " + RPAREN + " but found: " + tokenString(stream), stream.lineno()); } /** next word in the stream */ - private static void checkEOF(StreamTokenizer stream) throws ElasticsearchParseException, IOException { + private static void checkEOF(StreamTokenizer stream) throws OpenSearchParseException, IOException { if (stream.nextToken() != StreamTokenizer.TT_EOF) { - throw new ElasticsearchParseException("expected end of WKT string but found additional text: " + throw new OpenSearchParseException("expected end of WKT string but found additional text: " + tokenString(stream), stream.lineno()); } } diff --git a/server/src/main/java/org/elasticsearch/common/geo/parsers/ShapeParser.java b/server/src/main/java/org/elasticsearch/common/geo/parsers/ShapeParser.java index 06a99ee2ea317..0d05d5d0581cb 100644 --- a/server/src/main/java/org/elasticsearch/common/geo/parsers/ShapeParser.java +++ b/server/src/main/java/org/elasticsearch/common/geo/parsers/ShapeParser.java @@ -18,7 +18,7 @@ */ package org.elasticsearch.common.geo.parsers; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.common.ParseField; import org.elasticsearch.common.geo.builders.ShapeBuilder; import org.elasticsearch.common.xcontent.LoggingDeprecationHandler; @@ -66,7 +66,7 @@ static ShapeBuilder parse(XContentParser parser, AbstractGeometryFieldMapper geo } else if (parser.currentToken() == XContentParser.Token.VALUE_STRING) { return GeoWKTParser.parse(parser, shapeMapper); } - throw new ElasticsearchParseException("shape must be an object consisting of type and coordinates"); + throw new OpenSearchParseException("shape must be an object consisting of type and coordinates"); } /** diff --git a/server/src/main/java/org/elasticsearch/common/joda/JodaDateMathParser.java b/server/src/main/java/org/elasticsearch/common/joda/JodaDateMathParser.java index b7522c6a3233e..17058c67d146c 100644 --- a/server/src/main/java/org/elasticsearch/common/joda/JodaDateMathParser.java +++ b/server/src/main/java/org/elasticsearch/common/joda/JodaDateMathParser.java @@ -19,7 +19,7 @@ package org.elasticsearch.common.joda; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.common.time.DateMathParser; import org.elasticsearch.common.time.DateUtils; import org.joda.time.DateTimeZone; @@ -59,7 +59,7 @@ public Instant parse(String text, LongSupplier now, boolean roundUp, ZoneId tz) try { time = now.getAsLong(); } catch (Exception e) { - throw new ElasticsearchParseException("could not read the current timestamp", e); + throw new OpenSearchParseException("could not read the current timestamp", e); } mathString = text.substring("now".length()); } else { @@ -74,7 +74,7 @@ public Instant parse(String text, LongSupplier now, boolean roundUp, ZoneId tz) return Instant.ofEpochMilli(parseMath(mathString, time, roundUp, timeZone)); } - private long parseMath(String mathString, long time, boolean roundUp, DateTimeZone timeZone) throws ElasticsearchParseException { + private long parseMath(String mathString, long time, boolean roundUp, DateTimeZone timeZone) throws OpenSearchParseException { if (timeZone == null) { timeZone = DateTimeZone.UTC; } @@ -93,12 +93,12 @@ private long parseMath(String mathString, long time, boolean roundUp, DateTimeZo } else if (c == '-') { sign = -1; } else { - throw new ElasticsearchParseException("operator not supported for date math [{}]", mathString); + throw new OpenSearchParseException("operator not supported for date math [{}]", mathString); } } if (i >= mathString.length()) { - throw new ElasticsearchParseException("truncated date math [{}]", mathString); + throw new OpenSearchParseException("truncated date math [{}]", mathString); } final int num; @@ -110,13 +110,13 @@ private long parseMath(String mathString, long time, boolean roundUp, DateTimeZo i++; } if (i >= mathString.length()) { - throw new ElasticsearchParseException("truncated date math [{}]", mathString); + throw new OpenSearchParseException("truncated date math [{}]", mathString); } num = Integer.parseInt(mathString.substring(numFrom, i)); } if (round) { if (num != 1) { - throw new ElasticsearchParseException("rounding `/` can only be used on single unit types [{}]", mathString); + throw new OpenSearchParseException("rounding `/` can only be used on single unit types [{}]", mathString); } } char unit = mathString.charAt(i++); @@ -173,7 +173,7 @@ private long parseMath(String mathString, long time, boolean roundUp, DateTimeZo } break; default: - throw new ElasticsearchParseException("unit [{}] not supported for date math [{}]", unit, mathString); + throw new OpenSearchParseException("unit [{}] not supported for date math [{}]", unit, mathString); } if (propertyToRound != null) { if (roundUp) { @@ -212,7 +212,7 @@ private long parseDateTime(String value, DateTimeZone timeZone, boolean roundUpI } return date.getMillis(); } catch (IllegalArgumentException e) { - throw new ElasticsearchParseException("failed to parse date field [{}] with format [{}]", e, value, + throw new OpenSearchParseException("failed to parse date field [{}] with format [{}]", e, value, dateTimeFormatter.pattern()); } } diff --git a/server/src/main/java/org/elasticsearch/common/settings/Setting.java b/server/src/main/java/org/elasticsearch/common/settings/Setting.java index caf461b7cf53b..78c10517b095a 100644 --- a/server/src/main/java/org/elasticsearch/common/settings/Setting.java +++ b/server/src/main/java/org/elasticsearch/common/settings/Setting.java @@ -21,7 +21,7 @@ import org.apache.logging.log4j.Logger; import org.elasticsearch.OpenSearchException; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.Version; import org.elasticsearch.common.Booleans; import org.elasticsearch.common.Nullable; @@ -465,7 +465,7 @@ private T get(Settings settings, boolean validate) { validator.validate(parsed, map, exists(settings)); } return parsed; - } catch (ElasticsearchParseException ex) { + } catch (OpenSearchParseException ex) { throw new IllegalArgumentException(ex.getMessage(), ex); } catch (NumberFormatException ex) { String err = "Failed to parse value" + (isFiltered() ? "" : " [" + value + "]") + " for setting [" + getKey() + "]"; diff --git a/server/src/main/java/org/elasticsearch/common/settings/Settings.java b/server/src/main/java/org/elasticsearch/common/settings/Settings.java index f5a504964a6cd..11e1b75c4ffcc 100644 --- a/server/src/main/java/org/elasticsearch/common/settings/Settings.java +++ b/server/src/main/java/org/elasticsearch/common/settings/Settings.java @@ -22,7 +22,7 @@ import org.apache.logging.log4j.Level; import org.apache.lucene.util.SetOnce; import org.elasticsearch.OpenSearchGenerationException; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.Version; import org.elasticsearch.common.Booleans; import org.elasticsearch.common.Strings; @@ -624,13 +624,13 @@ private static Settings fromXContent(XContentParser parser, boolean allowNullVal try { while (!parser.isClosed() && (lastToken = parser.nextToken()) == null) ; } catch (Exception e) { - throw new ElasticsearchParseException( + throw new OpenSearchParseException( "malformed, expected end of settings but encountered additional content starting at line number: [{}], " + "column number: [{}]", e, parser.getTokenLocation().lineNumber, parser.getTokenLocation().columnNumber); } if (lastToken != null) { - throw new ElasticsearchParseException( + throw new OpenSearchParseException( "malformed, expected end of settings but encountered additional content starting at line number: [{}], " + "column number: [{}]", parser.getTokenLocation().lineNumber, parser.getTokenLocation().columnNumber); @@ -687,7 +687,7 @@ private static void fromXContent(XContentParser parser, StringBuilder keyBuilder private static void validateValue(String key, Object currentValue, XContentParser parser, boolean allowNullValues) { if (currentValue == null && allowNullValues == false) { - throw new ElasticsearchParseException( + throw new OpenSearchParseException( "null-valued setting found for key [{}] found at line number [{}], column number [{}]", key, parser.getTokenLocation().lineNumber, @@ -1107,7 +1107,7 @@ public Builder loadFromStream(String resourceName, InputStream is, boolean accep } } put(fromXContent(parser, acceptNullValues, true)); - } catch (ElasticsearchParseException e) { + } catch (OpenSearchParseException e) { throw e; } catch (Exception e) { throw new SettingsException("Failed to load settings from [" + resourceName + "]", e); diff --git a/server/src/main/java/org/elasticsearch/common/time/JavaDateMathParser.java b/server/src/main/java/org/elasticsearch/common/time/JavaDateMathParser.java index b3fd8fa0f277e..735cec389c4af 100644 --- a/server/src/main/java/org/elasticsearch/common/time/JavaDateMathParser.java +++ b/server/src/main/java/org/elasticsearch/common/time/JavaDateMathParser.java @@ -19,7 +19,7 @@ package org.elasticsearch.common.time; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.common.Strings; import java.time.DayOfWeek; @@ -65,7 +65,7 @@ public Instant parse(String text, LongSupplier now, boolean roundUpProperty, Zon // TODO only millisecond granularity here! time = Instant.ofEpochMilli(now.getAsLong()); } catch (Exception e) { - throw new ElasticsearchParseException("could not read the current timestamp", e); + throw new OpenSearchParseException("could not read the current timestamp", e); } mathString = text.substring("now".length()); } else { @@ -81,7 +81,7 @@ public Instant parse(String text, LongSupplier now, boolean roundUpProperty, Zon } private Instant parseMath(final String mathString, final Instant time, final boolean roundUpProperty, - ZoneId timeZone) throws ElasticsearchParseException { + ZoneId timeZone) throws OpenSearchParseException { if (timeZone == null) { timeZone = ZoneOffset.UTC; } @@ -100,12 +100,12 @@ private Instant parseMath(final String mathString, final Instant time, final boo } else if (c == '-') { sign = -1; } else { - throw new ElasticsearchParseException("operator not supported for date math [{}]", mathString); + throw new OpenSearchParseException("operator not supported for date math [{}]", mathString); } } if (i >= mathString.length()) { - throw new ElasticsearchParseException("truncated date math [{}]", mathString); + throw new OpenSearchParseException("truncated date math [{}]", mathString); } final int num; @@ -117,13 +117,13 @@ private Instant parseMath(final String mathString, final Instant time, final boo i++; } if (i >= mathString.length()) { - throw new ElasticsearchParseException("truncated date math [{}]", mathString); + throw new OpenSearchParseException("truncated date math [{}]", mathString); } num = Integer.parseInt(mathString.substring(numFrom, i)); } if (round) { if (num != 1) { - throw new ElasticsearchParseException("rounding `/` can only be used on single unit types [{}]", mathString); + throw new OpenSearchParseException("rounding `/` can only be used on single unit types [{}]", mathString); } } char unit = mathString.charAt(i++); @@ -200,7 +200,7 @@ private Instant parseMath(final String mathString, final Instant time, final boo } break; default: - throw new ElasticsearchParseException("unit [{}] not supported for date math [{}]", unit, mathString); + throw new OpenSearchParseException("unit [{}] not supported for date math [{}]", unit, mathString); } if (round && roundUpProperty) { // subtract 1 millisecond to get the largest inclusive value @@ -212,7 +212,7 @@ private Instant parseMath(final String mathString, final Instant time, final boo private Instant parseDateTime(String value, ZoneId timeZone, boolean roundUpIfNoTime) { if (Strings.isNullOrEmpty(value)) { - throw new ElasticsearchParseException("cannot parse empty date"); + throw new OpenSearchParseException("cannot parse empty date"); } DateFormatter formatter = roundUpIfNoTime ? this.roundupParser : this.formatter; @@ -229,7 +229,7 @@ private Instant parseDateTime(String value, ZoneId timeZone, boolean roundUpIfNo return DateFormatters.from(accessor).withZoneSameLocal(timeZone).toInstant(); } } catch (IllegalArgumentException | DateTimeParseException e) { - throw new ElasticsearchParseException("failed to parse date field [{}] with format [{}]: [{}]", + throw new OpenSearchParseException("failed to parse date field [{}] with format [{}]: [{}]", e, value, format, e.getMessage()); } } diff --git a/server/src/main/java/org/elasticsearch/common/unit/ByteSizeValue.java b/server/src/main/java/org/elasticsearch/common/unit/ByteSizeValue.java index aa4ecf5b730a9..e6bab82e3e089 100644 --- a/server/src/main/java/org/elasticsearch/common/unit/ByteSizeValue.java +++ b/server/src/main/java/org/elasticsearch/common/unit/ByteSizeValue.java @@ -19,7 +19,7 @@ package org.elasticsearch.common.unit; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.Version; import org.elasticsearch.common.Strings; import org.elasticsearch.common.io.stream.StreamInput; @@ -188,12 +188,12 @@ public String toString() { return Strings.format1Decimals(value, suffix); } - public static ByteSizeValue parseBytesSizeValue(String sValue, String settingName) throws ElasticsearchParseException { + public static ByteSizeValue parseBytesSizeValue(String sValue, String settingName) throws OpenSearchParseException { return parseBytesSizeValue(sValue, null, settingName); } public static ByteSizeValue parseBytesSizeValue(String sValue, ByteSizeValue defaultValue, String settingName) - throws ElasticsearchParseException { + throws OpenSearchParseException { settingName = Objects.requireNonNull(settingName); if (sValue == null) { return defaultValue; @@ -229,7 +229,7 @@ public static ByteSizeValue parseBytesSizeValue(String sValue, ByteSizeValue def return new ByteSizeValue(0, ByteSizeUnit.BYTES); } else { // Missing units: - throw new ElasticsearchParseException( + throw new OpenSearchParseException( "failed to parse setting [{}] with value [{}] as a size in bytes: unit is missing or unrecognized", settingName, sValue); } @@ -250,11 +250,11 @@ private static ByteSizeValue parse(final String initialInput, final String norma initialInput, settingName); return new ByteSizeValue((long) (doubleValue * unit.toBytes(1))); } catch (final NumberFormatException ignored) { - throw new ElasticsearchParseException("failed to parse [{}]", e, initialInput); + throw new OpenSearchParseException("failed to parse [{}]", e, initialInput); } } } catch (IllegalArgumentException e) { - throw new ElasticsearchParseException("failed to parse setting [{}] with value [{}] as a size in bytes", e, settingName, + throw new OpenSearchParseException("failed to parse setting [{}] with value [{}] as a size in bytes", e, settingName, initialInput); } } diff --git a/server/src/main/java/org/elasticsearch/common/unit/Fuzziness.java b/server/src/main/java/org/elasticsearch/common/unit/Fuzziness.java index 834277b5c7282..8f511019b080b 100644 --- a/server/src/main/java/org/elasticsearch/common/unit/Fuzziness.java +++ b/server/src/main/java/org/elasticsearch/common/unit/Fuzziness.java @@ -18,7 +18,7 @@ */ package org.elasticsearch.common.unit; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.Version; import org.elasticsearch.common.ParseField; import org.elasticsearch.common.io.stream.StreamInput; @@ -135,11 +135,11 @@ private static Fuzziness parseCustomAuto( final String string) { int highLimit = Integer.parseInt(fuzzinessLimit[1]); return new Fuzziness("AUTO", lowerLimit, highLimit); } catch (NumberFormatException e) { - throw new ElasticsearchParseException("failed to parse [{}] as a \"auto:int,int\"", e, + throw new OpenSearchParseException("failed to parse [{}] as a \"auto:int,int\"", e, string); } } else { - throw new ElasticsearchParseException("failed to find low and high distance values"); + throw new OpenSearchParseException("failed to find low and high distance values"); } } diff --git a/server/src/main/java/org/elasticsearch/common/unit/MemorySizeValue.java b/server/src/main/java/org/elasticsearch/common/unit/MemorySizeValue.java index 939664dd4d65a..a54aae427328b 100644 --- a/server/src/main/java/org/elasticsearch/common/unit/MemorySizeValue.java +++ b/server/src/main/java/org/elasticsearch/common/unit/MemorySizeValue.java @@ -19,7 +19,7 @@ package org.elasticsearch.common.unit; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.monitor.jvm.JvmInfo; import java.util.Objects; @@ -40,11 +40,11 @@ public static ByteSizeValue parseBytesSizeValueOrHeapRatio(String sValue, String try { final double percent = Double.parseDouble(percentAsString); if (percent < 0 || percent > 100) { - throw new ElasticsearchParseException("percentage should be in [0-100], got [{}]", percentAsString); + throw new OpenSearchParseException("percentage should be in [0-100], got [{}]", percentAsString); } return new ByteSizeValue((long) ((percent / 100) * JvmInfo.jvmInfo().getMem().getHeapMax().getBytes()), ByteSizeUnit.BYTES); } catch (NumberFormatException e) { - throw new ElasticsearchParseException("failed to parse [{}] as a double", e, percentAsString); + throw new OpenSearchParseException("failed to parse [{}] as a double", e, percentAsString); } } else { return parseBytesSizeValue(sValue, settingName); diff --git a/server/src/main/java/org/elasticsearch/common/unit/RatioValue.java b/server/src/main/java/org/elasticsearch/common/unit/RatioValue.java index 3893101a36645..52174da6a604f 100644 --- a/server/src/main/java/org/elasticsearch/common/unit/RatioValue.java +++ b/server/src/main/java/org/elasticsearch/common/unit/RatioValue.java @@ -19,7 +19,7 @@ package org.elasticsearch.common.unit; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; /** * Utility class to represent ratio and percentage values between 0 and 100 @@ -55,21 +55,21 @@ public static RatioValue parseRatioValue(String sValue) { try { final double percent = Double.parseDouble(percentAsString); if (percent < 0 || percent > 100) { - throw new ElasticsearchParseException("Percentage should be in [0-100], got [{}]", percentAsString); + throw new OpenSearchParseException("Percentage should be in [0-100], got [{}]", percentAsString); } return new RatioValue(Math.abs(percent)); } catch (NumberFormatException e) { - throw new ElasticsearchParseException("Failed to parse [{}] as a double", e, percentAsString); + throw new OpenSearchParseException("Failed to parse [{}] as a double", e, percentAsString); } } else { try { double ratio = Double.parseDouble(sValue); if (ratio < 0 || ratio > 1.0) { - throw new ElasticsearchParseException("Ratio should be in [0-1.0], got [{}]", ratio); + throw new OpenSearchParseException("Ratio should be in [0-1.0], got [{}]", ratio); } return new RatioValue(100.0 * Math.abs(ratio)); } catch (NumberFormatException e) { - throw new ElasticsearchParseException("Invalid ratio or percentage [{}]", sValue); + throw new OpenSearchParseException("Invalid ratio or percentage [{}]", sValue); } } diff --git a/server/src/main/java/org/elasticsearch/common/unit/SizeValue.java b/server/src/main/java/org/elasticsearch/common/unit/SizeValue.java index 0f90582007bfd..708de33d2b511 100644 --- a/server/src/main/java/org/elasticsearch/common/unit/SizeValue.java +++ b/server/src/main/java/org/elasticsearch/common/unit/SizeValue.java @@ -19,7 +19,7 @@ package org.elasticsearch.common.unit; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.common.Strings; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; @@ -167,11 +167,11 @@ public String toString() { return Strings.format1Decimals(value, suffix); } - public static SizeValue parseSizeValue(String sValue) throws ElasticsearchParseException { + public static SizeValue parseSizeValue(String sValue) throws OpenSearchParseException { return parseSizeValue(sValue, null); } - public static SizeValue parseSizeValue(String sValue, SizeValue defaultValue) throws ElasticsearchParseException { + public static SizeValue parseSizeValue(String sValue, SizeValue defaultValue) throws OpenSearchParseException { if (sValue == null) { return defaultValue; } @@ -191,7 +191,7 @@ public static SizeValue parseSizeValue(String sValue, SizeValue defaultValue) th singles = Long.parseLong(sValue); } } catch (NumberFormatException e) { - throw new ElasticsearchParseException("failed to parse [{}]", e, sValue); + throw new OpenSearchParseException("failed to parse [{}]", e, sValue); } return new SizeValue(singles, SizeUnit.SINGLE); } diff --git a/server/src/main/java/org/elasticsearch/common/xcontent/XContentHelper.java b/server/src/main/java/org/elasticsearch/common/xcontent/XContentHelper.java index 775b18f27708f..dcc47dbab42be 100644 --- a/server/src/main/java/org/elasticsearch/common/xcontent/XContentHelper.java +++ b/server/src/main/java/org/elasticsearch/common/xcontent/XContentHelper.java @@ -19,7 +19,7 @@ package org.elasticsearch.common.xcontent; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.common.Strings; import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.common.bytes.BytesReference; @@ -92,7 +92,7 @@ public static XContentParser createParser(NamedXContentRegistry xContentRegistry */ @Deprecated public static Tuple> convertToMap(BytesReference bytes, boolean ordered) - throws ElasticsearchParseException { + throws OpenSearchParseException { return convertToMap(bytes, ordered, null); } @@ -100,7 +100,7 @@ public static Tuple> convertToMap(BytesReferen * Converts the given bytes into a map that is optionally ordered. The provided {@link XContentType} must be non-null. */ public static Tuple> convertToMap(BytesReference bytes, boolean ordered, XContentType xContentType) - throws ElasticsearchParseException { + throws OpenSearchParseException { try { final XContentType contentType; InputStream input; @@ -129,51 +129,51 @@ public static Tuple> convertToMap(BytesReferen convertToMap(XContentFactory.xContent(contentType), stream, ordered)); } } catch (IOException e) { - throw new ElasticsearchParseException("Failed to parse content to map", e); + throw new OpenSearchParseException("Failed to parse content to map", e); } } /** - * Convert a string in some {@link XContent} format to a {@link Map}. Throws an {@link ElasticsearchParseException} if there is any + * Convert a string in some {@link XContent} format to a {@link Map}. Throws an {@link OpenSearchParseException} if there is any * error. */ - public static Map convertToMap(XContent xContent, String string, boolean ordered) throws ElasticsearchParseException { + public static Map convertToMap(XContent xContent, String string, boolean ordered) throws OpenSearchParseException { // It is safe to use EMPTY here because this never uses namedObject try (XContentParser parser = xContent.createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, string)) { return ordered ? parser.mapOrdered() : parser.map(); } catch (IOException e) { - throw new ElasticsearchParseException("Failed to parse content to map", e); + throw new OpenSearchParseException("Failed to parse content to map", e); } } /** - * Convert a string in some {@link XContent} format to a {@link Map}. Throws an {@link ElasticsearchParseException} if there is any + * Convert a string in some {@link XContent} format to a {@link Map}. Throws an {@link OpenSearchParseException} if there is any * error. Note that unlike {@link #convertToMap(BytesReference, boolean)}, this doesn't automatically uncompress the input. */ public static Map convertToMap(XContent xContent, InputStream input, boolean ordered) - throws ElasticsearchParseException { + throws OpenSearchParseException { // It is safe to use EMPTY here because this never uses namedObject try (XContentParser parser = xContent.createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, input)) { return ordered ? parser.mapOrdered() : parser.map(); } catch (IOException e) { - throw new ElasticsearchParseException("Failed to parse content to map", e); + throw new OpenSearchParseException("Failed to parse content to map", e); } } /** - * Convert a byte array in some {@link XContent} format to a {@link Map}. Throws an {@link ElasticsearchParseException} if there is any + * Convert a byte array in some {@link XContent} format to a {@link Map}. Throws an {@link OpenSearchParseException} if there is any * error. Note that unlike {@link #convertToMap(BytesReference, boolean)}, this doesn't automatically uncompress the input. */ public static Map convertToMap(XContent xContent, byte[] bytes, int offset, int length, boolean ordered) - throws ElasticsearchParseException { + throws OpenSearchParseException { // It is safe to use EMPTY here because this never uses namedObject try (XContentParser parser = xContent.createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, bytes, offset, length)) { return ordered ? parser.mapOrdered() : parser.map(); } catch (IOException e) { - throw new ElasticsearchParseException("Failed to parse content to map", e); + throw new OpenSearchParseException("Failed to parse content to map", e); } } diff --git a/server/src/main/java/org/elasticsearch/common/xcontent/support/XContentMapValues.java b/server/src/main/java/org/elasticsearch/common/xcontent/support/XContentMapValues.java index df5b419e527e9..e123edfc85368 100644 --- a/server/src/main/java/org/elasticsearch/common/xcontent/support/XContentMapValues.java +++ b/server/src/main/java/org/elasticsearch/common/xcontent/support/XContentMapValues.java @@ -23,7 +23,7 @@ import org.apache.lucene.util.automaton.Automaton; import org.apache.lucene.util.automaton.CharacterRunAutomaton; import org.apache.lucene.util.automaton.Operations; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.common.Booleans; import org.elasticsearch.common.Numbers; import org.elasticsearch.common.Strings; @@ -505,7 +505,7 @@ public static Map nodeMapValue(Object node, String desc) { if (node instanceof Map) { return (Map) node; } else { - throw new ElasticsearchParseException(desc + " should be a hash but was of type: " + node.getClass()); + throw new OpenSearchParseException(desc + " should be a hash but was of type: " + node.getClass()); } } diff --git a/server/src/main/java/org/elasticsearch/index/get/GetResult.java b/server/src/main/java/org/elasticsearch/index/get/GetResult.java index 3e7eb1f905461..727b582e916f9 100644 --- a/server/src/main/java/org/elasticsearch/index/get/GetResult.java +++ b/server/src/main/java/org/elasticsearch/index/get/GetResult.java @@ -19,7 +19,7 @@ package org.elasticsearch.index.get; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.Version; import org.elasticsearch.common.Strings; import org.elasticsearch.common.bytes.BytesReference; @@ -200,7 +200,7 @@ public BytesReference sourceRef() { this.source = CompressorFactory.uncompressIfNeeded(this.source); return this.source; } catch (IOException e) { - throw new ElasticsearchParseException("failed to decompress source", e); + throw new OpenSearchParseException("failed to decompress source", e); } } @@ -229,14 +229,14 @@ public String sourceAsString() { try { return XContentHelper.convertToJson(source, false); } catch (IOException e) { - throw new ElasticsearchParseException("failed to convert source to a json string"); + throw new OpenSearchParseException("failed to convert source to a json string"); } } /** * The source of the document (As a map). */ - public Map sourceAsMap() throws ElasticsearchParseException { + public Map sourceAsMap() throws OpenSearchParseException { if (source == null) { return null; } diff --git a/server/src/main/java/org/elasticsearch/index/mapper/AbstractPointGeometryFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/AbstractPointGeometryFieldMapper.java index ae37ee587d557..7a0b5c12c79a2 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/AbstractPointGeometryFieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/AbstractPointGeometryFieldMapper.java @@ -19,7 +19,7 @@ package org.elasticsearch.index.mapper; import org.apache.lucene.document.FieldType; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.common.CheckedBiFunction; import org.elasticsearch.common.Explicit; import org.elasticsearch.common.ParseField; @@ -220,7 +220,7 @@ public List

parse(XContentParser parser) throws IOException, ParseException { if (token == XContentParser.Token.VALUE_NUMBER) { GeoPoint.assertZValue(ignoreZValue, parser.doubleValue()); } else if (token != XContentParser.Token.END_ARRAY) { - throw new ElasticsearchParseException("field type does not accept > 3 dimensions"); + throw new OpenSearchParseException("field type does not accept > 3 dimensions"); } point.resetCoords(x, y); diff --git a/server/src/main/java/org/elasticsearch/index/mapper/DateFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/DateFieldMapper.java index 635ba77eeabc4..9cc5d20e71d74 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/DateFieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/DateFieldMapper.java @@ -28,7 +28,7 @@ import org.apache.lucene.search.IndexOrDocValuesQuery; import org.apache.lucene.search.IndexSortSortedNumericDocValuesRangeQuery; import org.apache.lucene.search.Query; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.Version; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.geo.ShapeRelation; @@ -611,7 +611,7 @@ protected void parseCreateField(ParseContext context) throws IOException { } else { try { timestamp = fieldType().parse(dateAsString); - } catch (IllegalArgumentException | ElasticsearchParseException | DateTimeException | ArithmeticException e) { + } catch (IllegalArgumentException | OpenSearchParseException | DateTimeException | ArithmeticException e) { if (ignoreMalformed) { context.addIgnoredField(mappedFieldType.name()); return; diff --git a/server/src/main/java/org/elasticsearch/index/mapper/DocumentParser.java b/server/src/main/java/org/elasticsearch/index/mapper/DocumentParser.java index 2fbe8f4e04b7e..ce27d8daa6a02 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/DocumentParser.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/DocumentParser.java @@ -21,7 +21,7 @@ import org.apache.lucene.document.Field; import org.apache.lucene.index.IndexableField; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.Version; import org.elasticsearch.common.Strings; import org.elasticsearch.common.collect.Tuple; @@ -685,7 +685,7 @@ private static Mapper.Builder createBuilderFromDynamicValue(final ParseContex for (DateFormatter dateTimeFormatter : context.root().dynamicDateTimeFormatters()) { try { dateTimeFormatter.parse(text); - } catch (ElasticsearchParseException | DateTimeParseException | IllegalArgumentException e) { + } catch (OpenSearchParseException | DateTimeParseException | IllegalArgumentException e) { // failure to parse this, continue continue; } diff --git a/server/src/main/java/org/elasticsearch/index/mapper/GeoPointFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/GeoPointFieldMapper.java index 82dcd581f3249..fd32993228b65 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/GeoPointFieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/GeoPointFieldMapper.java @@ -25,7 +25,7 @@ import org.apache.lucene.index.IndexOptions; import org.apache.lucene.index.IndexableField; import org.apache.lucene.search.Query; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.common.Explicit; import org.elasticsearch.common.geo.GeoPoint; import org.elasticsearch.common.geo.GeoUtils; @@ -224,7 +224,7 @@ public void normalize(String name) { if (isNormalizable(lat()) && isNormalizable(lon())) { GeoUtils.normalizePoint(this); } else { - throw new ElasticsearchParseException("cannot normalize the point - not a number"); + throw new OpenSearchParseException("cannot normalize the point - not a number"); } } diff --git a/server/src/main/java/org/elasticsearch/index/mapper/LegacyGeoShapeFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/LegacyGeoShapeFieldMapper.java index a7b47170d672a..9eb95993242c9 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/LegacyGeoShapeFieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/LegacyGeoShapeFieldMapper.java @@ -28,7 +28,7 @@ import org.apache.lucene.spatial.prefix.tree.PackedQuadPrefixTree; import org.apache.lucene.spatial.prefix.tree.QuadPrefixTree; import org.apache.lucene.spatial.prefix.tree.SpatialPrefixTree; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.Version; import org.elasticsearch.common.Explicit; import org.elasticsearch.common.ParseField; @@ -137,7 +137,7 @@ public void setPrecision(String precision) { public void setPointsOnly(boolean pointsOnly) { if (this.strategy == SpatialStrategy.TERM && pointsOnly == false) { - throw new ElasticsearchParseException("points_only cannot be set to false for term strategy"); + throw new OpenSearchParseException("points_only cannot be set to false for term strategy"); } this.pointsOnly = pointsOnly; } @@ -174,7 +174,7 @@ public static boolean parse(String name, String fieldName, Object fieldNode, Dep private static void checkPrefixTreeSupport(String fieldName) { if (ShapesAvailability.JTS_AVAILABLE == false || ShapesAvailability.SPATIAL4J_AVAILABLE == false) { - throw new ElasticsearchParseException("Field parameter [{}] is not supported for [{}] field type", + throw new OpenSearchParseException("Field parameter [{}] is not supported for [{}] field type", fieldName, CONTENT_TYPE); } DEPRECATION_LOGGER.deprecate("geo_mapper_field_parameter", diff --git a/server/src/main/java/org/elasticsearch/index/mapper/MappedFieldType.java b/server/src/main/java/org/elasticsearch/index/mapper/MappedFieldType.java index 5965ec74a70e7..2faea43ee021a 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/MappedFieldType.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/MappedFieldType.java @@ -38,7 +38,7 @@ import org.apache.lucene.search.spans.SpanMultiTermQueryWrapper; import org.apache.lucene.search.spans.SpanQuery; import org.apache.lucene.util.BytesRef; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.geo.ShapeRelation; import org.elasticsearch.common.time.DateMathParser; @@ -192,7 +192,7 @@ public boolean isAggregatable() { * boosted by {@link #boost()}. * @throws IllegalArgumentException if {@code value} cannot be converted to the expected data type or if the field is not searchable * due to the way it is configured (eg. not indexed) - * @throws ElasticsearchParseException if {@code value} cannot be converted to the expected data type + * @throws OpenSearchParseException if {@code value} cannot be converted to the expected data type * @throws UnsupportedOperationException if the field is not searchable regardless of options * @throws QueryShardException if the field is not searchable regardless of options */ diff --git a/server/src/main/java/org/elasticsearch/index/mapper/ObjectMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/ObjectMapper.java index 1dd39cb6365d5..c9ab394869d5f 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/ObjectMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/ObjectMapper.java @@ -23,7 +23,7 @@ import org.apache.lucene.search.Query; import org.apache.lucene.search.TermQuery; import org.apache.lucene.util.BytesRef; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.common.Explicit; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.collect.CopyOnWriteHashMap; @@ -231,7 +231,7 @@ protected static boolean parseObjectOrDocumentTypeProperties(String fieldName, O if (fieldNode instanceof Collection && ((Collection) fieldNode).isEmpty()) { // nothing to do here, empty (to support "properties: []" case) } else if (!(fieldNode instanceof Map)) { - throw new ElasticsearchParseException("properties must be a map type"); + throw new OpenSearchParseException("properties must be a map type"); } else { parseProperties(builder, (Map) fieldNode, parserContext); } diff --git a/server/src/main/java/org/elasticsearch/index/mapper/TypeParsers.java b/server/src/main/java/org/elasticsearch/index/mapper/TypeParsers.java index 375786ece7e64..c4d04adfabfa7 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/TypeParsers.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/TypeParsers.java @@ -20,7 +20,7 @@ package org.elasticsearch.index.mapper; import org.apache.lucene.index.IndexOptions; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.time.DateFormatter; import org.elasticsearch.common.xcontent.support.XContentMapValues; @@ -224,7 +224,7 @@ private static IndexOptions nodeIndexOptionValue(final Object propNode) { } else if (INDEX_OPTIONS_DOCS.equalsIgnoreCase(value)) { return IndexOptions.DOCS; } else { - throw new ElasticsearchParseException("failed to parse index option [{}]", value); + throw new OpenSearchParseException("failed to parse index option [{}]", value); } } diff --git a/server/src/main/java/org/elasticsearch/index/query/GeoBoundingBoxQueryBuilder.java b/server/src/main/java/org/elasticsearch/index/query/GeoBoundingBoxQueryBuilder.java index 59025dc03e161..2f8c10d037063 100644 --- a/server/src/main/java/org/elasticsearch/index/query/GeoBoundingBoxQueryBuilder.java +++ b/server/src/main/java/org/elasticsearch/index/query/GeoBoundingBoxQueryBuilder.java @@ -24,7 +24,7 @@ import org.apache.lucene.search.IndexOrDocValuesQuery; import org.apache.lucene.search.MatchNoDocsQuery; import org.apache.lucene.search.Query; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.common.Numbers; import org.elasticsearch.common.ParseField; import org.elasticsearch.common.ParsingException; @@ -387,7 +387,7 @@ public static GeoBoundingBoxQueryBuilder fromXContent(XContentParser parser) thr bbox = GeoBoundingBox.parseBoundingBox(parser); fieldName = currentFieldName; } catch (Exception e) { - throw new ElasticsearchParseException("failed to parse [{}] query. [{}]", NAME, e.getMessage()); + throw new OpenSearchParseException("failed to parse [{}] query. [{}]", NAME, e.getMessage()); } } else if (token.isValue()) { if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { @@ -408,7 +408,7 @@ public static GeoBoundingBoxQueryBuilder fromXContent(XContentParser parser) thr } if (bbox == null) { - throw new ElasticsearchParseException("failed to parse [{}] query. bounding box not provided", NAME); + throw new OpenSearchParseException("failed to parse [{}] query. bounding box not provided", NAME); } GeoBoundingBoxQueryBuilder builder = new GeoBoundingBoxQueryBuilder(fieldName); diff --git a/server/src/main/java/org/elasticsearch/index/query/MoreLikeThisQueryBuilder.java b/server/src/main/java/org/elasticsearch/index/query/MoreLikeThisQueryBuilder.java index 714c19cfb6fad..75a3eee1b5a91 100644 --- a/server/src/main/java/org/elasticsearch/index/query/MoreLikeThisQueryBuilder.java +++ b/server/src/main/java/org/elasticsearch/index/query/MoreLikeThisQueryBuilder.java @@ -24,7 +24,7 @@ import org.apache.lucene.search.BooleanClause; import org.apache.lucene.search.BooleanQuery; import org.apache.lucene.search.Query; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.ExceptionsHelper; import org.elasticsearch.action.RoutingMissingException; import org.elasticsearch.action.termvectors.MultiTermVectorsItemResponse; @@ -426,7 +426,7 @@ public static Item parse(XContentParser parser, Item item) throws IOException { } item.fields(fields.toArray(new String[fields.size()])); } else { - throw new ElasticsearchParseException( + throw new OpenSearchParseException( "failed to parse More Like This item. field [fields] must be an array"); } } else if (PER_FIELD_ANALYZER.match(currentFieldName, parser.getDeprecationHandler())) { @@ -438,17 +438,17 @@ public static Item parse(XContentParser parser, Item item) throws IOException { } else if (VERSION_TYPE.match(currentFieldName, parser.getDeprecationHandler())) { item.versionType = VersionType.fromString(parser.text()); } else { - throw new ElasticsearchParseException( + throw new OpenSearchParseException( "failed to parse More Like This item. unknown field [{}]", currentFieldName); } } } if (item.id != null && item.doc != null) { - throw new ElasticsearchParseException( + throw new OpenSearchParseException( "failed to parse More Like This item. either [id] or [doc] can be specified, but not both!"); } if (item.id == null && item.doc == null) { - throw new ElasticsearchParseException( + throw new OpenSearchParseException( "failed to parse More Like This item. neither [id] nor [doc] is specified!"); } return item; diff --git a/server/src/main/java/org/elasticsearch/index/query/MultiMatchQueryBuilder.java b/server/src/main/java/org/elasticsearch/index/query/MultiMatchQueryBuilder.java index 2a7c3729fe2b1..7d9a972cd5e09 100644 --- a/server/src/main/java/org/elasticsearch/index/query/MultiMatchQueryBuilder.java +++ b/server/src/main/java/org/elasticsearch/index/query/MultiMatchQueryBuilder.java @@ -21,7 +21,7 @@ import org.apache.lucene.search.FuzzyQuery; import org.apache.lucene.search.Query; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.Version; import org.elasticsearch.common.ParseField; import org.elasticsearch.common.ParsingException; @@ -172,7 +172,7 @@ public static Type parse(String value, DeprecationHandler deprecationHandler) { } } if (type == null) { - throw new ElasticsearchParseException("failed to parse [{}] query type [{}]. unknown type.", NAME, value); + throw new OpenSearchParseException("failed to parse [{}] query type [{}]. unknown type.", NAME, value); } return type; } diff --git a/server/src/main/java/org/elasticsearch/index/query/functionscore/DecayFunctionBuilder.java b/server/src/main/java/org/elasticsearch/index/query/functionscore/DecayFunctionBuilder.java index 47e08b1286ea3..9d34ca52aa1dd 100644 --- a/server/src/main/java/org/elasticsearch/index/query/functionscore/DecayFunctionBuilder.java +++ b/server/src/main/java/org/elasticsearch/index/query/functionscore/DecayFunctionBuilder.java @@ -21,7 +21,7 @@ import org.apache.lucene.index.LeafReaderContext; import org.apache.lucene.search.Explanation; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.common.ParsingException; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.geo.GeoDistance; @@ -247,11 +247,11 @@ private AbstractDistanceScoreFunction parseNumberVariable(XContentParser parser, } else if (DecayFunctionBuilder.OFFSET.equals(parameterName)) { offset = parser.doubleValue(); } else { - throw new ElasticsearchParseException("parameter [{}] not supported!", parameterName); + throw new OpenSearchParseException("parameter [{}] not supported!", parameterName); } } if (!scaleFound || !refFound) { - throw new ElasticsearchParseException("both [{}] and [{}] must be set for numeric fields.", DecayFunctionBuilder.SCALE, + throw new OpenSearchParseException("both [{}] and [{}] must be set for numeric fields.", DecayFunctionBuilder.SCALE, DecayFunctionBuilder.ORIGIN); } IndexNumericFieldData numericFieldData = context.getForField(fieldType); @@ -278,11 +278,11 @@ private AbstractDistanceScoreFunction parseGeoVariable(XContentParser parser, Qu } else if (DecayFunctionBuilder.OFFSET.equals(parameterName)) { offsetString = parser.text(); } else { - throw new ElasticsearchParseException("parameter [{}] not supported!", parameterName); + throw new OpenSearchParseException("parameter [{}] not supported!", parameterName); } } if (origin == null || scaleString == null) { - throw new ElasticsearchParseException("[{}] and [{}] must be set for geo fields.", DecayFunctionBuilder.ORIGIN, + throw new OpenSearchParseException("[{}] and [{}] must be set for geo fields.", DecayFunctionBuilder.ORIGIN, DecayFunctionBuilder.SCALE); } double scale = DistanceUnit.DEFAULT.parse(scaleString, DistanceUnit.DEFAULT); @@ -312,7 +312,7 @@ private AbstractDistanceScoreFunction parseDateVariable(XContentParser parser, Q } else if (DecayFunctionBuilder.OFFSET.equals(parameterName)) { offsetString = parser.text(); } else { - throw new ElasticsearchParseException("parameter [{}] not supported!", parameterName); + throw new OpenSearchParseException("parameter [{}] not supported!", parameterName); } } long origin; @@ -323,7 +323,7 @@ private AbstractDistanceScoreFunction parseDateVariable(XContentParser parser, Q } if (scaleString == null) { - throw new ElasticsearchParseException("[{}] must be set for date fields.", DecayFunctionBuilder.SCALE); + throw new OpenSearchParseException("[{}] must be set for date fields.", DecayFunctionBuilder.SCALE); } TimeValue val = TimeValue.parseTimeValue(scaleString, TimeValue.timeValueHours(24), DecayFunctionParser.class.getSimpleName() + ".scale"); diff --git a/server/src/main/java/org/elasticsearch/index/reindex/BulkByScrollResponse.java b/server/src/main/java/org/elasticsearch/index/reindex/BulkByScrollResponse.java index d2ea5f60a37a0..89fb999321c41 100644 --- a/server/src/main/java/org/elasticsearch/index/reindex/BulkByScrollResponse.java +++ b/server/src/main/java/org/elasticsearch/index/reindex/BulkByScrollResponse.java @@ -20,7 +20,7 @@ package org.elasticsearch.index.reindex; import org.elasticsearch.OpenSearchException; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.action.ActionResponse; import org.elasticsearch.action.bulk.BulkItemResponse.Failure; import org.elasticsearch.common.xcontent.ObjectParser; @@ -291,7 +291,7 @@ private static Object parseFailure(XContentParser parser) throws IOException { return new SearchFailure(searchExc, index, shardId, nodeId, RestStatus.fromCode(status)); } } else { - throw new ElasticsearchParseException("failed to parse failures array. At least one of {reason,cause} must be present"); + throw new OpenSearchParseException("failed to parse failures array. At least one of {reason,cause} must be present"); } } diff --git a/server/src/main/java/org/elasticsearch/index/search/QueryParserHelper.java b/server/src/main/java/org/elasticsearch/index/search/QueryParserHelper.java index fca92dd334b0c..267fb7842ab5c 100644 --- a/server/src/main/java/org/elasticsearch/index/search/QueryParserHelper.java +++ b/server/src/main/java/org/elasticsearch/index/search/QueryParserHelper.java @@ -19,7 +19,7 @@ package org.elasticsearch.index.search; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.regex.Regex; import org.elasticsearch.index.mapper.MappedFieldType; @@ -141,7 +141,7 @@ static Map resolveMappingField(QueryShardContext context, String } catch (QueryShardException | UnsupportedOperationException e) { // field type is never searchable with term queries (eg. geo point): ignore continue; - } catch (IllegalArgumentException | ElasticsearchParseException e) { + } catch (IllegalArgumentException | OpenSearchParseException e) { // other exceptions are parsing errors or not indexed fields: keep } } diff --git a/server/src/main/java/org/elasticsearch/index/snapshots/blobstore/BlobStoreIndexShardSnapshot.java b/server/src/main/java/org/elasticsearch/index/snapshots/blobstore/BlobStoreIndexShardSnapshot.java index 8cbc3a7b81b51..75490e33c33f7 100644 --- a/server/src/main/java/org/elasticsearch/index/snapshots/blobstore/BlobStoreIndexShardSnapshot.java +++ b/server/src/main/java/org/elasticsearch/index/snapshots/blobstore/BlobStoreIndexShardSnapshot.java @@ -21,7 +21,7 @@ import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.Version; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.common.ParseField; import org.elasticsearch.common.Strings; import org.elasticsearch.common.lucene.Lucene; @@ -308,28 +308,28 @@ public static FileInfo fromXContent(XContentParser parser) throws IOException { metaHash.offset = 0; metaHash.length = metaHash.bytes.length; } else { - throw new ElasticsearchParseException("unknown parameter [{}]", currentFieldName); + throw new OpenSearchParseException("unknown parameter [{}]", currentFieldName); } } else { - throw new ElasticsearchParseException("unexpected token [{}]", token); + throw new OpenSearchParseException("unexpected token [{}]", token); } } else { - throw new ElasticsearchParseException("unexpected token [{}]",token); + throw new OpenSearchParseException("unexpected token [{}]",token); } } } // Verify that file information is complete if (name == null || Strings.validFileName(name) == false) { - throw new ElasticsearchParseException("missing or invalid file name [" + name + "]"); + throw new OpenSearchParseException("missing or invalid file name [" + name + "]"); } else if (physicalName == null || Strings.validFileName(physicalName) == false) { - throw new ElasticsearchParseException("missing or invalid physical file name [" + physicalName + "]"); + throw new OpenSearchParseException("missing or invalid physical file name [" + physicalName + "]"); } else if (length < 0) { - throw new ElasticsearchParseException("missing or invalid file length"); + throw new OpenSearchParseException("missing or invalid file length"); } else if (writtenBy == null) { - throw new ElasticsearchParseException("missing or invalid written_by [" + writtenByStr + "]"); + throw new OpenSearchParseException("missing or invalid written_by [" + writtenByStr + "]"); } else if (checksum == null) { - throw new ElasticsearchParseException("missing checksum for name [" + name + "]"); + throw new OpenSearchParseException("missing checksum for name [" + name + "]"); } return new FileInfo(name, new StoreFileMetadata(physicalName, length, checksum, writtenBy, metaHash), partSize); } @@ -466,7 +466,7 @@ public long totalSize() { private static final String TIME = "time"; private static final String FILES = "files"; // for the sake of BWC keep the actual property names as in 6.x - // + there is a constraint in #fromXContent() that leads to ElasticsearchParseException("unknown parameter [incremental_file_count]"); + // + there is a constraint in #fromXContent() that leads to OpenSearchParseException("unknown parameter [incremental_file_count]"); private static final String INCREMENTAL_FILE_COUNT = "number_of_files"; private static final String INCREMENTAL_SIZE = "total_size"; @@ -540,7 +540,7 @@ public static BlobStoreIndexShardSnapshot fromXContent(XContentParser parser) th } else if (PARSE_INCREMENTAL_SIZE.match(currentFieldName, parser.getDeprecationHandler())) { incrementalSize = parser.longValue(); } else { - throw new ElasticsearchParseException("unknown parameter [{}]", currentFieldName); + throw new OpenSearchParseException("unknown parameter [{}]", currentFieldName); } } else if (token == XContentParser.Token.START_ARRAY) { if (PARSE_FILES.match(currentFieldName, parser.getDeprecationHandler())) { @@ -548,10 +548,10 @@ public static BlobStoreIndexShardSnapshot fromXContent(XContentParser parser) th indexFiles.add(FileInfo.fromXContent(parser)); } } else { - throw new ElasticsearchParseException("unknown parameter [{}]", currentFieldName); + throw new OpenSearchParseException("unknown parameter [{}]", currentFieldName); } } else { - throw new ElasticsearchParseException("unexpected token [{}]", token); + throw new OpenSearchParseException("unexpected token [{}]", token); } } } diff --git a/server/src/main/java/org/elasticsearch/index/snapshots/blobstore/BlobStoreIndexShardSnapshots.java b/server/src/main/java/org/elasticsearch/index/snapshots/blobstore/BlobStoreIndexShardSnapshots.java index 562d168929fa8..8d40d68357093 100644 --- a/server/src/main/java/org/elasticsearch/index/snapshots/blobstore/BlobStoreIndexShardSnapshots.java +++ b/server/src/main/java/org/elasticsearch/index/snapshots/blobstore/BlobStoreIndexShardSnapshots.java @@ -19,7 +19,7 @@ package org.elasticsearch.index.snapshots.blobstore; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.common.ParseField; import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.common.xcontent.XContentBuilder; @@ -267,7 +267,7 @@ public static BlobStoreIndexShardSnapshots fromXContent(XContentParser parser) t token = parser.nextToken(); if (token == XContentParser.Token.START_ARRAY) { if (ParseFields.FILES.match(currentFieldName, parser.getDeprecationHandler()) == false) { - throw new ElasticsearchParseException("unknown array [{}]", currentFieldName); + throw new OpenSearchParseException("unknown array [{}]", currentFieldName); } while (parser.nextToken() != XContentParser.Token.END_ARRAY) { FileInfo fileInfo = FileInfo.fromXContent(parser); @@ -275,7 +275,7 @@ public static BlobStoreIndexShardSnapshots fromXContent(XContentParser parser) t } } else if (token == XContentParser.Token.START_OBJECT) { if (ParseFields.SNAPSHOTS.match(currentFieldName, parser.getDeprecationHandler()) == false) { - throw new ElasticsearchParseException("unknown object [{}]", currentFieldName); + throw new OpenSearchParseException("unknown object [{}]", currentFieldName); } while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) { XContentParserUtils.ensureExpectedToken(XContentParser.Token.FIELD_NAME, token, parser); @@ -299,7 +299,7 @@ public static BlobStoreIndexShardSnapshots fromXContent(XContentParser parser) t } } } else { - throw new ElasticsearchParseException("unexpected token [{}]", token); + throw new OpenSearchParseException("unexpected token [{}]", token); } } } diff --git a/server/src/main/java/org/elasticsearch/ingest/ConfigurationUtils.java b/server/src/main/java/org/elasticsearch/ingest/ConfigurationUtils.java index 0b58068cdaa14..653200804450c 100644 --- a/server/src/main/java/org/elasticsearch/ingest/ConfigurationUtils.java +++ b/server/src/main/java/org/elasticsearch/ingest/ConfigurationUtils.java @@ -21,9 +21,9 @@ import java.io.IOException; import java.io.InputStream; -import org.elasticsearch.OpenSearchException; -import org.elasticsearch.ElasticsearchParseException; import org.elasticsearch.ExceptionsHelper; +import org.elasticsearch.OpenSearchException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.xcontent.LoggingDeprecationHandler; import org.elasticsearch.common.xcontent.NamedXContentRegistry; @@ -56,7 +56,7 @@ private ConfigurationUtils() { /** * Returns and removes the specified optional property from the specified configuration map. * - * If the property value isn't of type string a {@link ElasticsearchParseException} is thrown. + * If the property value isn't of type string a {@link OpenSearchParseException} is thrown. */ public static String readOptionalStringProperty(String processorType, String processorTag, Map configuration, String propertyName) { @@ -67,8 +67,8 @@ public static String readOptionalStringProperty(String processorType, String pro /** * Returns and removes the specified property from the specified configuration map. * - * If the property value isn't of type string an {@link ElasticsearchParseException} is thrown. - * If the property is missing an {@link ElasticsearchParseException} is thrown + * If the property value isn't of type string an {@link OpenSearchParseException} is thrown. + * If the property is missing an {@link OpenSearchParseException} is thrown */ public static String readStringProperty(String processorType, String processorTag, Map configuration, String propertyName) { @@ -78,8 +78,8 @@ public static String readStringProperty(String processorType, String processorTa /** * Returns and removes the specified property from the specified configuration map. * - * If the property value isn't of type string a {@link ElasticsearchParseException} is thrown. - * If the property is missing and no default value has been specified a {@link ElasticsearchParseException} is thrown + * If the property value isn't of type string a {@link OpenSearchParseException} is thrown. + * If the property is missing and no default value has been specified a {@link OpenSearchParseException} is thrown */ public static String readStringProperty(String processorType, String processorTag, Map configuration, String propertyName, String defaultValue) { @@ -106,8 +106,8 @@ private static String readString(String processorType, String processorTag, Stri /** * Returns and removes the specified property from the specified configuration map. * - * If the property value isn't of type string or int a {@link ElasticsearchParseException} is thrown. - * If the property is missing and no default value has been specified a {@link ElasticsearchParseException} is thrown + * If the property value isn't of type string or int a {@link OpenSearchParseException} is thrown. + * If the property is missing and no default value has been specified a {@link OpenSearchParseException} is thrown */ public static String readStringOrIntProperty(String processorType, String processorTag, Map configuration, String propertyName, String defaultValue) { @@ -138,7 +138,7 @@ private static String readStringOrInt(String processorType, String processorTag, /** * Returns and removes the specified property from the specified configuration map. * - * If the property value isn't of type string or int a {@link ElasticsearchParseException} is thrown. + * If the property value isn't of type string or int a {@link OpenSearchParseException} is thrown. */ public static String readOptionalStringOrIntProperty(String processorType, String processorTag, Map configuration, String propertyName) { @@ -173,8 +173,8 @@ private static Boolean readBoolean(String processorType, String processorTag, St /** * Returns and removes the specified property from the specified configuration map. * - * If the property value isn't of type int a {@link ElasticsearchParseException} is thrown. - * If the property is missing an {@link ElasticsearchParseException} is thrown + * If the property value isn't of type int a {@link OpenSearchParseException} is thrown. + * If the property is missing an {@link OpenSearchParseException} is thrown */ public static Integer readIntProperty(String processorType, String processorTag, Map configuration, String propertyName, Integer defaultValue) { @@ -193,8 +193,8 @@ public static Integer readIntProperty(String processorType, String processorTag, /** * Returns and removes the specified property from the specified configuration map. * - * If the property value isn't of type int a {@link ElasticsearchParseException} is thrown. - * If the property is missing an {@link ElasticsearchParseException} is thrown + * If the property value isn't of type int a {@link OpenSearchParseException} is thrown. + * If the property is missing an {@link OpenSearchParseException} is thrown */ public static Double readDoubleProperty(String processorType, String processorTag, Map configuration, String propertyName) { @@ -213,7 +213,7 @@ public static Double readDoubleProperty(String processorType, String processorTa /** * Returns and removes the specified property of type list from the specified configuration map. * - * If the property value isn't of type list an {@link ElasticsearchParseException} is thrown. + * If the property value isn't of type list an {@link OpenSearchParseException} is thrown. */ public static List readOptionalList(String processorType, String processorTag, Map configuration, String propertyName) { @@ -227,8 +227,8 @@ public static List readOptionalList(String processorType, String processo /** * Returns and removes the specified property of type list from the specified configuration map. * - * If the property value isn't of type list an {@link ElasticsearchParseException} is thrown. - * If the property is missing an {@link ElasticsearchParseException} is thrown + * If the property value isn't of type list an {@link OpenSearchParseException} is thrown. + * If the property is missing an {@link OpenSearchParseException} is thrown */ public static List readList(String processorType, String processorTag, Map configuration, String propertyName) { @@ -254,8 +254,8 @@ private static List readList(String processorType, String processorTag, S /** * Returns and removes the specified property of type map from the specified configuration map. * - * If the property value isn't of type map an {@link ElasticsearchParseException} is thrown. - * If the property is missing an {@link ElasticsearchParseException} is thrown + * If the property value isn't of type map an {@link OpenSearchParseException} is thrown. + * If the property is missing an {@link OpenSearchParseException} is thrown */ public static Map readMap(String processorType, String processorTag, Map configuration, String propertyName) { @@ -270,7 +270,7 @@ public static Map readMap(String processorType, String processorT /** * Returns and removes the specified property of type map from the specified configuration map. * - * If the property value isn't of type map an {@link ElasticsearchParseException} is thrown. + * If the property value isn't of type map an {@link OpenSearchParseException} is thrown. */ public static Map readOptionalMap(String processorType, String processorTag, Map configuration, String propertyName) { @@ -313,7 +313,7 @@ public static OpenSearchException newConfigurationException(String processorType } else { msg = "[" + propertyName + "] " + reason; } - ElasticsearchParseException exception = new ElasticsearchParseException(msg); + OpenSearchParseException exception = new OpenSearchParseException(msg); addMetadataToException(exception, processorType, processorTag, propertyName); return exception; } @@ -429,7 +429,7 @@ public static Processor readProcessor(Map processorFa try { Processor processor = factory.create(processorFactories, tag, description, config); if (config.isEmpty() == false) { - throw new ElasticsearchParseException("processor [{}] doesn't support one or more provided configuration parameters {}", + throw new OpenSearchParseException("processor [{}] doesn't support one or more provided configuration parameters {}", type, Arrays.toString(config.keySet().toArray())); } if (onFailureProcessors.size() > 0 || ignoreFailure) { diff --git a/server/src/main/java/org/elasticsearch/ingest/IngestService.java b/server/src/main/java/org/elasticsearch/ingest/IngestService.java index 2f79b17b07015..3b033bd4b0e8f 100644 --- a/server/src/main/java/org/elasticsearch/ingest/IngestService.java +++ b/server/src/main/java/org/elasticsearch/ingest/IngestService.java @@ -22,7 +22,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.ExceptionsHelper; import org.elasticsearch.ResourceNotFoundException; import org.elasticsearch.action.ActionListener; @@ -708,7 +708,7 @@ public void applyClusterState(final ClusterChangedEvent event) { try { innerUpdatePipelines(newIngestMetadata); - } catch (ElasticsearchParseException e) { + } catch (OpenSearchParseException e) { logger.warn("failed to update ingest pipelines", e); } } @@ -718,7 +718,7 @@ void innerUpdatePipelines(IngestMetadata newIngestMetadata) { // Lazy initialize these variables in order to favour the most like scenario that there are no pipeline changes: Map newPipelines = null; - List exceptions = null; + List exceptions = null; // Iterate over pipeline configurations in ingest metadata and constructs a new pipeline if there is no pipeline // or the pipeline configuration has been modified for (PipelineConfiguration newConfiguration : newIngestMetadata.getPipelines().values()) { @@ -765,7 +765,7 @@ void innerUpdatePipelines(IngestMetadata newIngestMetadata) { } } } - } catch (ElasticsearchParseException e) { + } catch (OpenSearchParseException e) { Pipeline pipeline = substitutePipeline(newConfiguration.getId(), e); newPipelines.put(newConfiguration.getId(), new PipelineHolder(newConfiguration, pipeline)); if (exceptions == null) { @@ -773,7 +773,7 @@ void innerUpdatePipelines(IngestMetadata newIngestMetadata) { } exceptions.add(e); } catch (Exception e) { - ElasticsearchParseException parseException = new ElasticsearchParseException( + OpenSearchParseException parseException = new OpenSearchParseException( "Error updating pipeline with id [" + newConfiguration.getId() + "]", e); Pipeline pipeline = substitutePipeline(newConfiguration.getId(), parseException); newPipelines.put(newConfiguration.getId(), new PipelineHolder(newConfiguration, pipeline)); @@ -841,7 +841,7 @@ public

List

getProcessorsInPipeline(String pipelineId, C return processors; } - private static Pipeline substitutePipeline(String id, ElasticsearchParseException e) { + private static Pipeline substitutePipeline(String id, OpenSearchParseException e) { String tag = e.getHeaderKeys().contains("processor_tag") ? e.getHeader("processor_tag").get(0) : null; String type = e.getHeaderKeys().contains("processor_type") ? e.getHeader("processor_type").get(0) : "unknown"; String errorMessage = "pipeline with id [" + id + "] could not be loaded, caused by [" + e.getDetailedMessage() + "]"; diff --git a/server/src/main/java/org/elasticsearch/ingest/Pipeline.java b/server/src/main/java/org/elasticsearch/ingest/Pipeline.java index 3d41d991f3e10..755d6cd3a9541 100644 --- a/server/src/main/java/org/elasticsearch/ingest/Pipeline.java +++ b/server/src/main/java/org/elasticsearch/ingest/Pipeline.java @@ -19,7 +19,7 @@ package org.elasticsearch.ingest; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.common.Nullable; import java.util.Arrays; @@ -77,11 +77,11 @@ public static Pipeline create(String id, Map config, List onFailureProcessors = ConfigurationUtils.readProcessorConfigs(onFailureProcessorConfigs, scriptService, processorFactories); if (config.isEmpty() == false) { - throw new ElasticsearchParseException("pipeline [" + id + + throw new OpenSearchParseException("pipeline [" + id + "] doesn't support one or more provided configuration parameters " + Arrays.toString(config.keySet().toArray())); } if (onFailureProcessorConfigs != null && onFailureProcessors.isEmpty()) { - throw new ElasticsearchParseException("pipeline [" + id + "] cannot have an empty on_failure option defined"); + throw new OpenSearchParseException("pipeline [" + id + "] cannot have an empty on_failure option defined"); } CompoundProcessor compoundProcessor = new CompoundProcessor(false, Collections.unmodifiableList(processors), Collections.unmodifiableList(onFailureProcessors)); diff --git a/server/src/main/java/org/elasticsearch/repositories/RepositoryData.java b/server/src/main/java/org/elasticsearch/repositories/RepositoryData.java index 32b479f535624..b90fc479790a7 100644 --- a/server/src/main/java/org/elasticsearch/repositories/RepositoryData.java +++ b/server/src/main/java/org/elasticsearch/repositories/RepositoryData.java @@ -19,7 +19,7 @@ package org.elasticsearch.repositories; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.ResourceNotFoundException; import org.elasticsearch.Version; import org.elasticsearch.common.Nullable; @@ -700,7 +700,7 @@ private static void parseIndices(XContentParser parser, boolean fixBrokenShardGe // A snapshotted index references a snapshot which does not exist in // the list of snapshots. This can happen when multiple clusters in // different versions create or delete snapshot in the same repository. - throw new ElasticsearchParseException("Detected a corrupted repository, index " + indexId + throw new OpenSearchParseException("Detected a corrupted repository, index " + indexId + " references an unknown snapshot uuid [" + uuid + "]"); } snapshotIds.add(snapshotId); diff --git a/server/src/main/java/org/elasticsearch/rest/RestRequest.java b/server/src/main/java/org/elasticsearch/rest/RestRequest.java index eb7dcc24d555f..a89c3e76c6dae 100644 --- a/server/src/main/java/org/elasticsearch/rest/RestRequest.java +++ b/server/src/main/java/org/elasticsearch/rest/RestRequest.java @@ -20,7 +20,7 @@ package org.elasticsearch.rest; import org.apache.lucene.util.SetOnce; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.common.Booleans; import org.elasticsearch.common.CheckedConsumer; import org.elasticsearch.common.Nullable; @@ -226,7 +226,7 @@ protected BytesReference content(final boolean contentConsumed) { */ public final BytesReference requiredContent() { if (hasContent() == false) { - throw new ElasticsearchParseException("request body is required"); + throw new OpenSearchParseException("request body is required"); } else if (xContentType.get() == null) { throw new IllegalStateException("unknown content type"); } @@ -416,7 +416,7 @@ public NamedXContentRegistry getXContentRegistry() { } /** - * A parser for the contents of this request if there is a body, otherwise throws an {@link ElasticsearchParseException}. Use + * A parser for the contents of this request if there is a body, otherwise throws an {@link OpenSearchParseException}. Use * {@link #applyContentParser(CheckedConsumer)} if you want to gracefully handle when the request doesn't have any contents. Use * {@link #contentOrSourceParamParser()} for requests that support specifying the request body in the {@code source} param. */ @@ -446,7 +446,7 @@ public final boolean hasContentOrSourceParam() { /** * A parser for the contents of this request if it has contents, otherwise a parser for the {@code source} parameter if there is one, - * otherwise throws an {@link ElasticsearchParseException}. Use {@link #withContentOrSourceParamParserOrNull(CheckedConsumer)} instead + * otherwise throws an {@link OpenSearchParseException}. Use {@link #withContentOrSourceParamParserOrNull(CheckedConsumer)} instead * if you need to handle the absence request content gracefully. */ public final XContentParser contentOrSourceParamParser() throws IOException { @@ -480,7 +480,7 @@ public final void withContentOrSourceParamParserOrNull(CheckedConsumer contentOrSourceParam() { if (hasContentOrSourceParam() == false) { - throw new ElasticsearchParseException("request body or source parameter is required"); + throw new OpenSearchParseException("request body or source parameter is required"); } else if (hasContent()) { return new Tuple<>(xContentType.get(), requiredContent()); } diff --git a/server/src/main/java/org/elasticsearch/script/Script.java b/server/src/main/java/org/elasticsearch/script/Script.java index 0c79338e328e4..4c9ceee07d77f 100644 --- a/server/src/main/java/org/elasticsearch/script/Script.java +++ b/server/src/main/java/org/elasticsearch/script/Script.java @@ -19,7 +19,7 @@ package org.elasticsearch.script; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.common.ParseField; import org.elasticsearch.common.Strings; import org.elasticsearch.common.bytes.BytesArray; @@ -433,33 +433,33 @@ public static Script parse(Object config) { if (parameterValue instanceof String || parameterValue == null) { lang = (String) parameterValue; } else { - throw new ElasticsearchParseException("Value must be of type String: [" + parameterName + "]"); + throw new OpenSearchParseException("Value must be of type String: [" + parameterName + "]"); } } else if (Script.PARAMS_PARSE_FIELD.match(parameterName, LoggingDeprecationHandler.INSTANCE)) { if (parameterValue instanceof Map || parameterValue == null) { params = (Map) parameterValue; } else { - throw new ElasticsearchParseException("Value must be of type Map: [" + parameterName + "]"); + throw new OpenSearchParseException("Value must be of type Map: [" + parameterName + "]"); } } else if (Script.OPTIONS_PARSE_FIELD.match(parameterName, LoggingDeprecationHandler.INSTANCE)) { if (parameterValue instanceof Map || parameterValue == null) { options = (Map) parameterValue; } else { - throw new ElasticsearchParseException("Value must be of type Map: [" + parameterName + "]"); + throw new OpenSearchParseException("Value must be of type Map: [" + parameterName + "]"); } } else if (ScriptType.INLINE.getParseField().match(parameterName, LoggingDeprecationHandler.INSTANCE)) { if (parameterValue instanceof String || parameterValue == null) { script = (String) parameterValue; type = ScriptType.INLINE; } else { - throw new ElasticsearchParseException("Value must be of type String: [" + parameterName + "]"); + throw new OpenSearchParseException("Value must be of type String: [" + parameterName + "]"); } } else if (ScriptType.STORED.getParseField().match(parameterName, LoggingDeprecationHandler.INSTANCE)) { if (parameterValue instanceof String || parameterValue == null) { script = (String) parameterValue; type = ScriptType.STORED; } else { - throw new ElasticsearchParseException("Value must be of type String: [" + parameterName + "]"); + throw new OpenSearchParseException("Value must be of type String: [" + parameterName + "]"); } } else { deprecationLogger.deprecate("script_unsupported_fields", "script section does not support [" @@ -467,7 +467,7 @@ public static Script parse(Object config) { } } if (script == null) { - throw new ElasticsearchParseException("Expected one of [{}] or [{}] fields, but found none", + throw new OpenSearchParseException("Expected one of [{}] or [{}] fields, but found none", ScriptType.INLINE.getParseField().getPreferredName(), ScriptType.STORED.getParseField().getPreferredName()); } assert type != null : "if script is not null, type should definitely not be null"; diff --git a/server/src/main/java/org/elasticsearch/search/SearchHit.java b/server/src/main/java/org/elasticsearch/search/SearchHit.java index 7c4f216dc550a..2b8c5c799bc81 100644 --- a/server/src/main/java/org/elasticsearch/search/SearchHit.java +++ b/server/src/main/java/org/elasticsearch/search/SearchHit.java @@ -20,7 +20,7 @@ package org.elasticsearch.search; import org.apache.lucene.search.Explanation; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.Version; import org.elasticsearch.action.OriginalIndices; import org.elasticsearch.common.Nullable; @@ -388,7 +388,7 @@ public BytesReference getSourceRef() { this.source = CompressorFactory.uncompressIfNeeded(this.source); return this.source; } catch (IOException e) { - throw new ElasticsearchParseException("failed to decompress source", e); + throw new OpenSearchParseException("failed to decompress source", e); } } @@ -419,7 +419,7 @@ public String getSourceAsString() { try { return XContentHelper.convertToJson(getSourceRef(), false); } catch (IOException e) { - throw new ElasticsearchParseException("failed to convert source to a json string"); + throw new OpenSearchParseException("failed to convert source to a json string"); } } diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/Aggregator.java b/server/src/main/java/org/elasticsearch/search/aggregations/Aggregator.java index 061640e73b510..aa0be809e35ce 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/Aggregator.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/Aggregator.java @@ -19,7 +19,7 @@ package org.elasticsearch.search.aggregations; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.common.ParseField; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; @@ -174,7 +174,7 @@ public final InternalAggregation buildTopLevel() throws IOException { * also only add objects which can be serialized with * {@link StreamOutput#writeGenericValue(Object)} and * {@link XContentBuilder#value(Object)}. And they'll have an integration - * test. + * test. */ public void collectDebugInfo(BiConsumer add) {} @@ -213,7 +213,7 @@ public static SubAggCollectionMode parse(String value, DeprecationHandler deprec return mode; } } - throw new ElasticsearchParseException("no [{}] found for value [{}]", KEY.getPreferredName(), value); + throw new OpenSearchParseException("no [{}] found for value [{}]", KEY.getPreferredName(), value); } public static SubAggCollectionMode readFromStream(StreamInput in) throws IOException { diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/GeoTileUtils.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/GeoTileUtils.java index 909e8b584184e..507f96943454e 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/GeoTileUtils.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/GeoTileUtils.java @@ -20,7 +20,7 @@ import org.apache.lucene.geo.GeoEncodingUtils; import org.apache.lucene.util.SloppyMath; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.common.geo.GeoPoint; import org.elasticsearch.common.util.ESSloppyMath; import org.elasticsearch.common.xcontent.ObjectParser.ValueType; @@ -89,7 +89,7 @@ private GeoTileUtils() {} * @param parser {@link XContentParser} to parse the value from * @return int representing precision */ - static int parsePrecision(XContentParser parser) throws IOException, ElasticsearchParseException { + static int parsePrecision(XContentParser parser) throws IOException, OpenSearchParseException { final Object node = parser.currentToken().equals(XContentParser.Token.VALUE_NUMBER) ? Integer.valueOf(parser.intValue()) : parser.text(); diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/IncludeExclude.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/IncludeExclude.java index 30653f04a355a..5bb2d7ac627d4 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/IncludeExclude.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/IncludeExclude.java @@ -35,7 +35,7 @@ import org.apache.lucene.util.automaton.CompiledAutomaton; import org.apache.lucene.util.automaton.Operations; import org.apache.lucene.util.automaton.RegExp; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.common.ParseField; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; @@ -108,7 +108,7 @@ public static IncludeExclude parseInclude(XContentParser parser) throws IOExcept } else if (PARTITION_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { partition = parser.intValue(); } else { - throw new ElasticsearchParseException( + throw new OpenSearchParseException( "Unknown parameter in Include/Exclude clause: " + currentFieldName); } } @@ -552,11 +552,11 @@ public boolean hasPayloads() { private static Set parseArrayToSet(XContentParser parser) throws IOException { final Set set = new HashSet<>(); if (parser.currentToken() != XContentParser.Token.START_ARRAY) { - throw new ElasticsearchParseException("Missing start of array in include/exclude clause"); + throw new OpenSearchParseException("Missing start of array in include/exclude clause"); } while (parser.nextToken() != XContentParser.Token.END_ARRAY) { if (!parser.currentToken().isValue()) { - throw new ElasticsearchParseException("Array elements in include/exclude clauses should be string values"); + throw new OpenSearchParseException("Array elements in include/exclude clauses should be string values"); } set.add(new BytesRef(parser.text())); } diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/heuristic/PercentageScore.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/heuristic/PercentageScore.java index 937ff297fa513..b52d5126d9303 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/heuristic/PercentageScore.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/heuristic/PercentageScore.java @@ -21,7 +21,7 @@ package org.elasticsearch.search.aggregations.bucket.terms.heuristic; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.xcontent.ObjectParser; @@ -61,7 +61,7 @@ public static SignificanceHeuristic parse(XContentParser parser) throws IOException, QueryShardException { // move to the closing bracket if (!parser.nextToken().equals(XContentParser.Token.END_OBJECT)) { - throw new ElasticsearchParseException("failed to parse [percentage] significance heuristic. expected an empty object, " + + throw new OpenSearchParseException("failed to parse [percentage] significance heuristic. expected an empty object, " + "but got [{}] instead", parser.currentToken()); } return new PercentageScore(); diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/HoltWintersModel.java b/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/HoltWintersModel.java index ed33a1b3049b6..12f5b9397c4a6 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/HoltWintersModel.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/HoltWintersModel.java @@ -20,7 +20,7 @@ package org.elasticsearch.search.aggregations.pipeline; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.ParseField; import org.elasticsearch.common.io.stream.StreamInput; @@ -75,7 +75,7 @@ public static SeasonalityType parse(String text) { for (SeasonalityType policy : values()) { validNames.add(policy.getName()); } - throw new ElasticsearchParseException("failed to parse seasonality type [{}]. accepted values are [{}]", text, validNames); + throw new OpenSearchParseException("failed to parse seasonality type [{}]. accepted values are [{}]", text, validNames); } return result; } diff --git a/server/src/main/java/org/elasticsearch/search/lookup/LeafFieldsLookup.java b/server/src/main/java/org/elasticsearch/search/lookup/LeafFieldsLookup.java index eb440537c4a31..8fe878be857f2 100644 --- a/server/src/main/java/org/elasticsearch/search/lookup/LeafFieldsLookup.java +++ b/server/src/main/java/org/elasticsearch/search/lookup/LeafFieldsLookup.java @@ -19,7 +19,7 @@ package org.elasticsearch.search.lookup; import org.apache.lucene.index.LeafReader; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.common.Nullable; import org.elasticsearch.index.fieldvisitor.SingleFieldsVisitor; import org.elasticsearch.index.mapper.DocumentMapper; @@ -156,7 +156,7 @@ private FieldLookup loadFieldData(String name) { try { reader.document(docId, visitor); } catch (IOException e) { - throw new ElasticsearchParseException("failed to load field [{}]", e, name); + throw new OpenSearchParseException("failed to load field [{}]", e, name); } } data.fields(singletonMap(data.fieldType().name(), values)); diff --git a/server/src/main/java/org/elasticsearch/search/lookup/SourceLookup.java b/server/src/main/java/org/elasticsearch/search/lookup/SourceLookup.java index e5be3b21b782a..b5f7a74513ebe 100644 --- a/server/src/main/java/org/elasticsearch/search/lookup/SourceLookup.java +++ b/server/src/main/java/org/elasticsearch/search/lookup/SourceLookup.java @@ -20,7 +20,7 @@ import org.apache.lucene.index.LeafReader; import org.apache.lucene.index.LeafReaderContext; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.common.CheckedBiConsumer; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.bytes.BytesReference; @@ -91,16 +91,16 @@ public Map loadSourceIfNeeded() { this.source = tuple.v2(); } } catch (Exception e) { - throw new ElasticsearchParseException("failed to parse / load source", e); + throw new OpenSearchParseException("failed to parse / load source", e); } return this.source; } - private static Tuple> sourceAsMapAndType(BytesReference source) throws ElasticsearchParseException { + private static Tuple> sourceAsMapAndType(BytesReference source) throws OpenSearchParseException { return XContentHelper.convertToMap(source, false); } - public static Map sourceAsMap(BytesReference source) throws ElasticsearchParseException { + public static Map sourceAsMap(BytesReference source) throws OpenSearchParseException { return sourceAsMapAndType(source).v2(); } diff --git a/server/src/main/java/org/elasticsearch/search/sort/FieldSortBuilder.java b/server/src/main/java/org/elasticsearch/search/sort/FieldSortBuilder.java index 1151c4348a2e3..a8c1dfc037c0b 100644 --- a/server/src/main/java/org/elasticsearch/search/sort/FieldSortBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/sort/FieldSortBuilder.java @@ -25,7 +25,7 @@ import org.apache.lucene.index.PointValues; import org.apache.lucene.index.Terms; import org.apache.lucene.search.SortField; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.Version; import org.elasticsearch.common.ParseField; import org.elasticsearch.common.io.stream.StreamInput; @@ -464,7 +464,7 @@ public boolean isBottomSortShardDisjoint(QueryShardContext context, SearchSortVa MappedFieldType.Relation relation = fieldType.isFieldWithinQuery(context.getIndexReader(), minValue, maxValue, true, true, null, dateMathParser, context); return relation == MappedFieldType.Relation.DISJOINT; - } catch (ElasticsearchParseException exc) { + } catch (OpenSearchParseException exc) { // can happen if the sort field is mapped differently in another search index return false; } diff --git a/server/src/main/java/org/elasticsearch/search/sort/GeoDistanceSortBuilder.java b/server/src/main/java/org/elasticsearch/search/sort/GeoDistanceSortBuilder.java index 3e3b9dc7f2ca4..e50cde7efc12b 100644 --- a/server/src/main/java/org/elasticsearch/search/sort/GeoDistanceSortBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/sort/GeoDistanceSortBuilder.java @@ -28,7 +28,7 @@ import org.apache.lucene.search.SortField; import org.apache.lucene.search.comparators.DoubleComparator; import org.apache.lucene.util.BitSet; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.Version; import org.elasticsearch.common.ParseField; import org.elasticsearch.common.ParsingException; @@ -621,13 +621,13 @@ private GeoPoint[] localPoints() { if (GeoValidationMethod.isIgnoreMalformed(validation) == false) { for (GeoPoint point : localPoints) { if (GeoUtils.isValidLatitude(point.lat()) == false) { - throw new ElasticsearchParseException( + throw new OpenSearchParseException( "illegal latitude value [{}] for [GeoDistanceSort] for field [{}].", point.lat(), fieldName); } if (GeoUtils.isValidLongitude(point.lon()) == false) { - throw new ElasticsearchParseException( + throw new OpenSearchParseException( "illegal longitude value [{}] for [GeoDistanceSort] for field [{}].", point.lon(), fieldName); @@ -753,7 +753,7 @@ static void parseGeoPoints(XContentParser parser, List geoPoints) thro double lon = parser.doubleValue(); parser.nextToken(); if (!parser.currentToken().equals(XContentParser.Token.VALUE_NUMBER)) { - throw new ElasticsearchParseException( + throw new OpenSearchParseException( "geo point parsing: expected second number but got [{}] instead", parser.currentToken()); } diff --git a/server/src/main/java/org/elasticsearch/search/suggest/SuggestionBuilder.java b/server/src/main/java/org/elasticsearch/search/suggest/SuggestionBuilder.java index 3f7844a79926c..76b16751c6419 100644 --- a/server/src/main/java/org/elasticsearch/search/suggest/SuggestionBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/suggest/SuggestionBuilder.java @@ -20,7 +20,7 @@ package org.elasticsearch.search.suggest; import org.apache.lucene.analysis.Analyzer; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.common.ParseField; import org.elasticsearch.common.ParsingException; import org.elasticsearch.common.io.stream.NamedWriteable; @@ -278,7 +278,7 @@ static SuggestionBuilder fromXContent(XContentParser parser) throws IOExcepti } } if (suggestionBuilder == null) { - throw new ElasticsearchParseException("missing suggestion object"); + throw new OpenSearchParseException("missing suggestion object"); } if (suggestText != null) { suggestionBuilder.text(suggestText); diff --git a/server/src/main/java/org/elasticsearch/search/suggest/completion/CompletionSuggestionBuilder.java b/server/src/main/java/org/elasticsearch/search/suggest/completion/CompletionSuggestionBuilder.java index 08b978bc0c999..bc4606adefa5a 100644 --- a/server/src/main/java/org/elasticsearch/search/suggest/completion/CompletionSuggestionBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/suggest/completion/CompletionSuggestionBuilder.java @@ -18,7 +18,7 @@ */ package org.elasticsearch.search.suggest.completion; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.Version; import org.elasticsearch.common.ParseField; import org.elasticsearch.common.bytes.BytesReference; @@ -279,7 +279,7 @@ public static CompletionSuggestionBuilder fromXContent(XContentParser parser) th String field = builder.field; // now we should have field name, check and copy fields over to the suggestion builder we return if (field == null) { - throw new ElasticsearchParseException( + throw new OpenSearchParseException( "the required field option [" + FIELDNAME_FIELD.getPreferredName() + "] is missing"); } return new CompletionSuggestionBuilder(field, builder); diff --git a/server/src/main/java/org/elasticsearch/search/suggest/completion/RegexOptions.java b/server/src/main/java/org/elasticsearch/search/suggest/completion/RegexOptions.java index da42ea6e0cbb2..a8ee7dc347b14 100644 --- a/server/src/main/java/org/elasticsearch/search/suggest/completion/RegexOptions.java +++ b/server/src/main/java/org/elasticsearch/search/suggest/completion/RegexOptions.java @@ -21,7 +21,7 @@ import org.apache.lucene.util.automaton.Operations; import org.apache.lucene.util.automaton.RegExp; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.common.ParseField; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; @@ -58,7 +58,7 @@ public class RegexOptions implements ToXContentFragment, Writeable { } else if (parser.currentToken() == XContentParser.Token.VALUE_NUMBER) { builder.setFlagsValue(parser.intValue()); } else { - throw new ElasticsearchParseException(REGEX_OPTIONS.getPreferredName() + throw new OpenSearchParseException(REGEX_OPTIONS.getPreferredName() + " " + FLAGS_VALUE.getPreferredName() + " supports string or number"); } }, FLAGS_VALUE, ObjectParser.ValueType.VALUE); diff --git a/server/src/main/java/org/elasticsearch/search/suggest/completion/context/CategoryContextMapping.java b/server/src/main/java/org/elasticsearch/search/suggest/completion/context/CategoryContextMapping.java index feadc41807154..ecf1e38afafac 100644 --- a/server/src/main/java/org/elasticsearch/search/suggest/completion/context/CategoryContextMapping.java +++ b/server/src/main/java/org/elasticsearch/search/suggest/completion/context/CategoryContextMapping.java @@ -23,7 +23,7 @@ import org.apache.lucene.document.SortedSetDocValuesField; import org.apache.lucene.document.StoredField; import org.apache.lucene.index.IndexableField; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.Version; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; @@ -82,7 +82,7 @@ public String getFieldName() { * * Acceptable map param: path */ - protected static CategoryContextMapping load(String name, Map config) throws ElasticsearchParseException { + protected static CategoryContextMapping load(String name, Map config) throws OpenSearchParseException { CategoryContextMapping.Builder mapping = new CategoryContextMapping.Builder(name); Object fieldName = config.get(FIELD_FIELDNAME); if (fieldName != null) { @@ -111,7 +111,7 @@ protected XContentBuilder toInnerXContent(XContentBuilder builder, Params params */ @Override public Set parseContext(ParseContext parseContext, XContentParser parser) - throws IOException, ElasticsearchParseException { + throws IOException, OpenSearchParseException { final Set contexts = new HashSet<>(); Token token = parser.currentToken(); if (token == Token.VALUE_STRING || token == Token.VALUE_NUMBER || token == Token.VALUE_BOOLEAN) { @@ -121,12 +121,12 @@ public Set parseContext(ParseContext parseContext, XContentParser parser if (token == Token.VALUE_STRING || token == Token.VALUE_NUMBER || token == Token.VALUE_BOOLEAN) { contexts.add(parser.text()); } else { - throw new ElasticsearchParseException( + throw new OpenSearchParseException( "context array must have string, number or boolean values, but was [" + token + "]"); } } } else { - throw new ElasticsearchParseException( + throw new OpenSearchParseException( "contexts must be a string, number or boolean or a list of string, number or boolean, but was [" + token + "]"); } return contexts; diff --git a/server/src/main/java/org/elasticsearch/search/suggest/completion/context/ContextMapping.java b/server/src/main/java/org/elasticsearch/search/suggest/completion/context/ContextMapping.java index 96891ef8a9869..e726d40fd7107 100644 --- a/server/src/main/java/org/elasticsearch/search/suggest/completion/context/ContextMapping.java +++ b/server/src/main/java/org/elasticsearch/search/suggest/completion/context/ContextMapping.java @@ -19,7 +19,7 @@ package org.elasticsearch.search.suggest.completion.context; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.Version; import org.elasticsearch.common.Strings; import org.elasticsearch.common.xcontent.ToXContent; @@ -95,7 +95,7 @@ public String name() { * Parses a set of index-time contexts. */ public abstract Set parseContext(ParseContext parseContext, XContentParser parser) - throws IOException, ElasticsearchParseException; + throws IOException, OpenSearchParseException; /** * Retrieves a set of context from a document at index-time. @@ -110,7 +110,7 @@ public abstract Set parseContext(ParseContext parseContext, XContentPars /** * Parses query contexts for this mapper */ - public final List parseQueryContext(XContentParser parser) throws IOException, ElasticsearchParseException { + public final List parseQueryContext(XContentParser parser) throws IOException, OpenSearchParseException { List queryContexts = new ArrayList<>(); Token token = parser.nextToken(); if (token == Token.START_ARRAY) { diff --git a/server/src/main/java/org/elasticsearch/search/suggest/completion/context/ContextMappings.java b/server/src/main/java/org/elasticsearch/search/suggest/completion/context/ContextMappings.java index 7ebb62806ff80..c79351bad0ca0 100644 --- a/server/src/main/java/org/elasticsearch/search/suggest/completion/context/ContextMappings.java +++ b/server/src/main/java/org/elasticsearch/search/suggest/completion/context/ContextMappings.java @@ -24,7 +24,7 @@ import org.apache.lucene.search.suggest.document.ContextSuggestField; import org.apache.lucene.util.CharsRef; import org.apache.lucene.util.CharsRefBuilder; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.Version; import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.XContentBuilder; @@ -224,7 +224,7 @@ public Map> getNamedContexts(List contexts) { * [{"name": .., "type": .., ..}, {..}] * */ - public static ContextMappings load(Object configuration, Version indexVersionCreated) throws ElasticsearchParseException { + public static ContextMappings load(Object configuration, Version indexVersionCreated) throws OpenSearchParseException { final List> contextMappings; if (configuration instanceof List) { contextMappings = new ArrayList<>(); @@ -233,12 +233,12 @@ public static ContextMappings load(Object configuration, Version indexVersionCre contextMappings.add(load((Map) contextConfig, indexVersionCreated)); } if (contextMappings.size() == 0) { - throw new ElasticsearchParseException("expected at least one context mapping"); + throw new OpenSearchParseException("expected at least one context mapping"); } } else if (configuration instanceof Map) { contextMappings = Collections.singletonList(load(((Map) configuration), indexVersionCreated)); } else { - throw new ElasticsearchParseException("expected a list or an entry of context mapping"); + throw new OpenSearchParseException("expected a list or an entry of context mapping"); } return new ContextMappings(contextMappings); } @@ -255,7 +255,7 @@ private static ContextMapping load(Map contextConfig, Version contextMapping = GeoContextMapping.load(name, contextConfig); break; default: - throw new ElasticsearchParseException("unknown context type[" + type + "]"); + throw new OpenSearchParseException("unknown context type[" + type + "]"); } DocumentMapperParser.checkNoRemainingFields(name, contextConfig, indexVersionCreated); return contextMapping; @@ -264,7 +264,7 @@ private static ContextMapping load(Map contextConfig, Version private static String extractRequiredValue(Map contextConfig, String paramName) { final Object paramValue = contextConfig.get(paramName); if (paramValue == null) { - throw new ElasticsearchParseException("missing [" + paramName + "] in context mapping"); + throw new OpenSearchParseException("missing [" + paramName + "] in context mapping"); } contextConfig.remove(paramName); return paramValue.toString(); diff --git a/server/src/main/java/org/elasticsearch/search/suggest/completion/context/GeoContextMapping.java b/server/src/main/java/org/elasticsearch/search/suggest/completion/context/GeoContextMapping.java index 2c8b97e82e300..c319ba542ac6c 100644 --- a/server/src/main/java/org/elasticsearch/search/suggest/completion/context/GeoContextMapping.java +++ b/server/src/main/java/org/elasticsearch/search/suggest/completion/context/GeoContextMapping.java @@ -24,7 +24,7 @@ import org.apache.lucene.document.StringField; import org.apache.lucene.index.DocValuesType; import org.apache.lucene.index.IndexableField; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.Version; import org.elasticsearch.common.geo.GeoPoint; import org.elasticsearch.common.geo.GeoUtils; @@ -143,11 +143,11 @@ protected XContentBuilder toInnerXContent(XContentBuilder builder, Params params * see {@code GeoPoint(String)} for GEO POINT */ @Override - public Set parseContext(ParseContext parseContext, XContentParser parser) throws IOException, ElasticsearchParseException { + public Set parseContext(ParseContext parseContext, XContentParser parser) throws IOException, OpenSearchParseException { if (fieldName != null) { MappedFieldType fieldType = parseContext.mapperService().fieldType(fieldName); if (!(fieldType instanceof GeoPointFieldMapper.GeoPointFieldType)) { - throw new ElasticsearchParseException("referenced field must be mapped to geo_point"); + throw new OpenSearchParseException("referenced field must be mapped to geo_point"); } } final Set contexts = new HashSet<>(); @@ -162,10 +162,10 @@ public Set parseContext(ParseContext parseContext, XContentParser parser if (parser.nextToken() == Token.END_ARRAY) { contexts.add(stringEncode(lon, lat, precision)); } else { - throw new ElasticsearchParseException("only two values [lon, lat] expected"); + throw new OpenSearchParseException("only two values [lon, lat] expected"); } } else { - throw new ElasticsearchParseException("latitude must be a numeric value"); + throw new OpenSearchParseException("latitude must be a numeric value"); } } else { while (token != Token.END_ARRAY) { @@ -298,7 +298,7 @@ public void validateReferences(Version indexVersionCreated, Function parser() { if (p.currentToken() == XContentParser.Token.VALUE_STRING) { return new TaskId(p.text()); } - throw new ElasticsearchParseException("Expected a string but found [{}] instead", p.currentToken()); + throw new OpenSearchParseException("Expected a string but found [{}] instead", p.currentToken()); }; } diff --git a/server/src/test/java/org/elasticsearch/ExceptionSerializationTests.java b/server/src/test/java/org/elasticsearch/ExceptionSerializationTests.java index 577168a4c8512..0d52fe52b5eb7 100644 --- a/server/src/test/java/org/elasticsearch/ExceptionSerializationTests.java +++ b/server/src/test/java/org/elasticsearch/ExceptionSerializationTests.java @@ -709,7 +709,7 @@ public void testIds() { ids.put(32, org.elasticsearch.indices.InvalidIndexNameException.class); ids.put(33, org.elasticsearch.indices.IndexPrimaryShardNotAllocatedException.class); ids.put(34, org.elasticsearch.transport.TransportException.class); - ids.put(35, org.elasticsearch.ElasticsearchParseException.class); + ids.put(35, OpenSearchParseException.class); ids.put(36, org.elasticsearch.search.SearchException.class); ids.put(37, org.elasticsearch.index.mapper.MapperException.class); ids.put(38, org.elasticsearch.indices.InvalidTypeNameException.class); diff --git a/server/src/test/java/org/elasticsearch/action/admin/indices/create/CreateIndexRequestBuilderTests.java b/server/src/test/java/org/elasticsearch/action/admin/indices/create/CreateIndexRequestBuilderTests.java index 2dd8a8343c501..0025b019aec0f 100644 --- a/server/src/test/java/org/elasticsearch/action/admin/indices/create/CreateIndexRequestBuilderTests.java +++ b/server/src/test/java/org/elasticsearch/action/admin/indices/create/CreateIndexRequestBuilderTests.java @@ -19,7 +19,7 @@ package org.elasticsearch.action.admin.indices.create; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; @@ -60,11 +60,11 @@ public void tearDown() throws Exception { */ public void testSetSource() throws IOException { CreateIndexRequestBuilder builder = new CreateIndexRequestBuilder(this.testClient, CreateIndexAction.INSTANCE); - - ElasticsearchParseException e = expectThrows(ElasticsearchParseException.class, + + OpenSearchParseException e = expectThrows(OpenSearchParseException.class, () -> {builder.setSource("{\""+KEY+"\" : \""+VALUE+"\"}", XContentType.JSON);}); assertEquals(String.format(Locale.ROOT, "unknown key [%s] for create index", KEY), e.getMessage()); - + builder.setSource("{\"settings\" : {\""+KEY+"\" : \""+VALUE+"\"}}", XContentType.JSON); assertEquals(VALUE, builder.request().settings().get(KEY)); diff --git a/server/src/test/java/org/elasticsearch/action/admin/indices/create/CreateIndexRequestTests.java b/server/src/test/java/org/elasticsearch/action/admin/indices/create/CreateIndexRequestTests.java index e3e18f6d55a6f..d9b315f2b7ceb 100644 --- a/server/src/test/java/org/elasticsearch/action/admin/indices/create/CreateIndexRequestTests.java +++ b/server/src/test/java/org/elasticsearch/action/admin/indices/create/CreateIndexRequestTests.java @@ -19,7 +19,7 @@ package org.elasticsearch.action.admin.indices.create; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.action.admin.indices.alias.Alias; import org.elasticsearch.common.Strings; import org.elasticsearch.common.bytes.BytesReference; @@ -82,7 +82,7 @@ public void testTopLevelKeys() { + "}"; CreateIndexRequest request = new CreateIndexRequest(); - ElasticsearchParseException e = expectThrows(ElasticsearchParseException.class, + OpenSearchParseException e = expectThrows(OpenSearchParseException.class, () -> {request.source(createIndex, XContentType.JSON);}); assertEquals("unknown key [FOO_SHOULD_BE_ILLEGAL_HERE] for create index", e.getMessage()); } @@ -202,7 +202,7 @@ public void testSettingsType() throws IOException { builder.startObject().startArray("settings").endArray().endObject(); CreateIndexRequest parsedCreateIndexRequest = new CreateIndexRequest(); - ElasticsearchParseException e = expectThrows(ElasticsearchParseException.class, () -> parsedCreateIndexRequest.source(builder)); + OpenSearchParseException e = expectThrows(OpenSearchParseException.class, () -> parsedCreateIndexRequest.source(builder)); assertThat(e.getMessage(), equalTo("key [settings] must be an object")); } diff --git a/server/src/test/java/org/elasticsearch/action/ingest/SimulatePipelineRequestParsingTests.java b/server/src/test/java/org/elasticsearch/action/ingest/SimulatePipelineRequestParsingTests.java index 9ec20f1c45d2b..cc0989a27e925 100644 --- a/server/src/test/java/org/elasticsearch/action/ingest/SimulatePipelineRequestParsingTests.java +++ b/server/src/test/java/org/elasticsearch/action/ingest/SimulatePipelineRequestParsingTests.java @@ -19,7 +19,7 @@ package org.elasticsearch.action.ingest; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.index.VersionType; import org.elasticsearch.ingest.CompoundProcessor; import org.elasticsearch.ingest.IngestDocument; @@ -152,7 +152,7 @@ private void innerTestParseWithProvidedPipeline(boolean useExplicitType) throws for (int i = 0; i < numDocs; i++) { Map doc = new HashMap<>(); Map expectedDoc = new HashMap<>(); - List fields = Arrays.asList(INDEX, TYPE, ID, ROUTING, VERSION, VERSION_TYPE, IF_SEQ_NO, + List fields = Arrays.asList(INDEX, TYPE, ID, ROUTING, VERSION, VERSION_TYPE, IF_SEQ_NO, IF_PRIMARY_TERM); for(IngestDocument.Metadata field : fields) { if (field == VERSION) { @@ -293,7 +293,7 @@ public void testNotValidDocs() { docs.add(new HashMap<>()); requestContent.put(Fields.DOCS, docs); requestContent.put(Fields.PIPELINE, pipelineConfig); - Exception e3 = expectThrows(ElasticsearchParseException.class, + Exception e3 = expectThrows(OpenSearchParseException.class, () -> SimulatePipelineRequest.parse(requestContent, false, ingestService)); assertThat(e3.getMessage(), containsString("required property is missing")); } diff --git a/server/src/test/java/org/elasticsearch/cluster/metadata/DateMathExpressionResolverTests.java b/server/src/test/java/org/elasticsearch/cluster/metadata/DateMathExpressionResolverTests.java index 1dcaa697f996c..e4b5ebd51818b 100644 --- a/server/src/test/java/org/elasticsearch/cluster/metadata/DateMathExpressionResolverTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/metadata/DateMathExpressionResolverTests.java @@ -19,7 +19,7 @@ package org.elasticsearch.cluster.metadata; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.action.support.IndicesOptions; import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.ClusterState; @@ -155,28 +155,28 @@ public void testExpression_CustomTimeZoneInIndexName() throws Exception { } public void testExpressionInvalidUnescaped() throws Exception { - Exception e = expectThrows(ElasticsearchParseException.class, + Exception e = expectThrows(OpenSearchParseException.class, () -> expressionResolver.resolve(context, Arrays.asList("<.mar}vel-{now/d}>"))); assertThat(e.getMessage(), containsString("invalid dynamic name expression")); assertThat(e.getMessage(), containsString("invalid character at position [")); } public void testExpressionInvalidDateMathFormat() throws Exception { - Exception e = expectThrows(ElasticsearchParseException.class, + Exception e = expectThrows(OpenSearchParseException.class, () -> expressionResolver.resolve(context, Arrays.asList("<.marvel-{now/d{}>"))); assertThat(e.getMessage(), containsString("invalid dynamic name expression")); assertThat(e.getMessage(), containsString("date math placeholder is open ended")); } public void testExpressionInvalidEmptyDateMathFormat() throws Exception { - Exception e = expectThrows(ElasticsearchParseException.class, + Exception e = expectThrows(OpenSearchParseException.class, () -> expressionResolver.resolve(context, Arrays.asList("<.marvel-{now/d{}}>"))); assertThat(e.getMessage(), containsString("invalid dynamic name expression")); assertThat(e.getMessage(), containsString("missing date format")); } public void testExpressionInvalidOpenEnded() throws Exception { - Exception e = expectThrows(ElasticsearchParseException.class, + Exception e = expectThrows(OpenSearchParseException.class, () -> expressionResolver.resolve(context, Arrays.asList("<.marvel-{now/d>"))); assertThat(e.getMessage(), containsString("invalid dynamic name expression")); assertThat(e.getMessage(), containsString("date math placeholder is open ended")); diff --git a/server/src/test/java/org/elasticsearch/common/geo/GeoBoundingBoxTests.java b/server/src/test/java/org/elasticsearch/common/geo/GeoBoundingBoxTests.java index 983d8f35bfacf..4ddd7c8f7db76 100644 --- a/server/src/test/java/org/elasticsearch/common/geo/GeoBoundingBoxTests.java +++ b/server/src/test/java/org/elasticsearch/common/geo/GeoBoundingBoxTests.java @@ -20,7 +20,7 @@ package org.elasticsearch.common.geo; import org.apache.lucene.geo.GeoEncodingUtils; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentParser; @@ -46,7 +46,7 @@ public void testInvalidParseInvalidWKT() throws IOException { .endObject(); XContentParser parser = createParser(bboxBuilder); parser.nextToken(); - ElasticsearchParseException e = expectThrows(ElasticsearchParseException.class, () -> GeoBoundingBox.parseBoundingBox(parser)); + OpenSearchParseException e = expectThrows(OpenSearchParseException.class, () -> GeoBoundingBox.parseBoundingBox(parser)); assertThat(e.getMessage(), equalTo("failed to parse WKT bounding box")); } @@ -57,7 +57,7 @@ public void testInvalidParsePoint() throws IOException { .endObject(); XContentParser parser = createParser(bboxBuilder); parser.nextToken(); - ElasticsearchParseException e = expectThrows(ElasticsearchParseException.class, () -> GeoBoundingBox.parseBoundingBox(parser)); + OpenSearchParseException e = expectThrows(OpenSearchParseException.class, () -> GeoBoundingBox.parseBoundingBox(parser)); assertThat(e.getMessage(), equalTo("failed to parse WKT bounding box. [POINT] found. expected [ENVELOPE]")); } diff --git a/server/src/test/java/org/elasticsearch/common/geo/GeoJsonShapeParserTests.java b/server/src/test/java/org/elasticsearch/common/geo/GeoJsonShapeParserTests.java index dbfabbd991300..b1869ff7cca10 100644 --- a/server/src/test/java/org/elasticsearch/common/geo/GeoJsonShapeParserTests.java +++ b/server/src/test/java/org/elasticsearch/common/geo/GeoJsonShapeParserTests.java @@ -19,7 +19,7 @@ package org.elasticsearch.common.geo; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.Version; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.common.Strings; @@ -165,7 +165,7 @@ public void testParseMultiDimensionShapes() throws IOException { XContentParser parser = createParser(pointGeoJson); parser.nextToken(); - ElasticsearchGeoAssertions.assertValidException(parser, ElasticsearchParseException.class); + ElasticsearchGeoAssertions.assertValidException(parser, OpenSearchParseException.class); assertNull(parser.nextToken()); // multi dimension linestring @@ -180,7 +180,7 @@ public void testParseMultiDimensionShapes() throws IOException { parser = createParser(lineGeoJson); parser.nextToken(); - ElasticsearchGeoAssertions.assertValidException(parser, ElasticsearchParseException.class); + ElasticsearchGeoAssertions.assertValidException(parser, OpenSearchParseException.class); assertNull(parser.nextToken()); } @@ -221,7 +221,7 @@ public void testParseEnvelope() throws IOException, ParseException { .endObject(); try (XContentParser parser = createParser(multilinesGeoJson)) { parser.nextToken(); - ElasticsearchGeoAssertions.assertValidException(parser, ElasticsearchParseException.class); + ElasticsearchGeoAssertions.assertValidException(parser, OpenSearchParseException.class); assertNull(parser.nextToken()); } @@ -232,7 +232,7 @@ public void testParseEnvelope() throws IOException, ParseException { .endObject(); try (XContentParser parser = createParser(multilinesGeoJson)) { parser.nextToken(); - ElasticsearchGeoAssertions.assertValidException(parser, ElasticsearchParseException.class); + ElasticsearchGeoAssertions.assertValidException(parser, OpenSearchParseException.class); assertNull(parser.nextToken()); } } @@ -333,7 +333,7 @@ public void testInvalidDimensionalPolygon() throws IOException { .endObject(); try (XContentParser parser = createParser(polygonGeoJson)) { parser.nextToken(); - ElasticsearchGeoAssertions.assertValidException(parser, ElasticsearchParseException.class); + ElasticsearchGeoAssertions.assertValidException(parser, OpenSearchParseException.class); assertNull(parser.nextToken()); } } @@ -349,7 +349,7 @@ public void testParseInvalidPoint() throws IOException { .endObject(); try (XContentParser parser = createParser(invalidPoint1)) { parser.nextToken(); - ElasticsearchGeoAssertions.assertValidException(parser, ElasticsearchParseException.class); + ElasticsearchGeoAssertions.assertValidException(parser, OpenSearchParseException.class); assertNull(parser.nextToken()); } @@ -362,7 +362,7 @@ public void testParseInvalidPoint() throws IOException { .endObject(); try (XContentParser parser = createParser(invalidPoint2)) { parser.nextToken(); - ElasticsearchGeoAssertions.assertValidException(parser, ElasticsearchParseException.class); + ElasticsearchGeoAssertions.assertValidException(parser, OpenSearchParseException.class); assertNull(parser.nextToken()); } } @@ -376,7 +376,7 @@ public void testParseInvalidMultipoint() throws IOException { .endObject(); try (XContentParser parser = createParser(invalidMultipoint1)) { parser.nextToken(); - ElasticsearchGeoAssertions.assertValidException(parser, ElasticsearchParseException.class); + ElasticsearchGeoAssertions.assertValidException(parser, OpenSearchParseException.class); assertNull(parser.nextToken()); } @@ -389,7 +389,7 @@ public void testParseInvalidMultipoint() throws IOException { .endObject(); try (XContentParser parser = createParser(invalidMultipoint2)) { parser.nextToken(); - ElasticsearchGeoAssertions.assertValidException(parser, ElasticsearchParseException.class); + ElasticsearchGeoAssertions.assertValidException(parser, OpenSearchParseException.class); assertNull(parser.nextToken()); } @@ -403,7 +403,7 @@ public void testParseInvalidMultipoint() throws IOException { .endObject(); try (XContentParser parser = createParser(invalidMultipoint3)) { parser.nextToken(); - ElasticsearchGeoAssertions.assertValidException(parser, ElasticsearchParseException.class); + ElasticsearchGeoAssertions.assertValidException(parser, OpenSearchParseException.class); assertNull(parser.nextToken()); } } @@ -481,7 +481,7 @@ public void testParseInvalidDimensionalMultiPolygon() throws IOException { try (XContentParser parser = createParser(JsonXContent.jsonXContent, multiPolygonGeoJson)) { parser.nextToken(); - ElasticsearchGeoAssertions.assertValidException(parser, ElasticsearchParseException.class); + ElasticsearchGeoAssertions.assertValidException(parser, OpenSearchParseException.class); assertNull(parser.nextToken()); } } @@ -731,7 +731,7 @@ public void testParseInvalidPolygon() throws IOException { .endObject()); try (XContentParser parser = createParser(JsonXContent.jsonXContent, invalidPoly)) { parser.nextToken(); - ElasticsearchGeoAssertions.assertValidException(parser, ElasticsearchParseException.class); + ElasticsearchGeoAssertions.assertValidException(parser, OpenSearchParseException.class); assertNull(parser.nextToken()); } @@ -746,7 +746,7 @@ public void testParseInvalidPolygon() throws IOException { try (XContentParser parser = createParser(JsonXContent.jsonXContent, invalidPoly)) { parser.nextToken(); - ElasticsearchGeoAssertions.assertValidException(parser, ElasticsearchParseException.class); + ElasticsearchGeoAssertions.assertValidException(parser, OpenSearchParseException.class); assertNull(parser.nextToken()); } @@ -761,7 +761,7 @@ public void testParseInvalidPolygon() throws IOException { try (XContentParser parser = createParser(JsonXContent.jsonXContent, invalidPoly)) { parser.nextToken(); - ElasticsearchGeoAssertions.assertValidException(parser, ElasticsearchParseException.class); + ElasticsearchGeoAssertions.assertValidException(parser, OpenSearchParseException.class); assertNull(parser.nextToken()); } @@ -800,7 +800,7 @@ public void testParseInvalidPolygon() throws IOException { try (XContentParser parser = createParser(JsonXContent.jsonXContent, invalidPoly)) { parser.nextToken(); - ElasticsearchGeoAssertions.assertValidException(parser, ElasticsearchParseException.class); + ElasticsearchGeoAssertions.assertValidException(parser, OpenSearchParseException.class); assertNull(parser.nextToken()); } @@ -813,7 +813,7 @@ public void testParseInvalidPolygon() throws IOException { try (XContentParser parser = createParser(JsonXContent.jsonXContent, invalidPoly)) { parser.nextToken(); - ElasticsearchGeoAssertions.assertValidException(parser, ElasticsearchParseException.class); + ElasticsearchGeoAssertions.assertValidException(parser, OpenSearchParseException.class); assertNull(parser.nextToken()); } } @@ -1379,7 +1379,7 @@ public void testParseInvalidShapes() throws IOException { try (XContentParser parser = createParser(tooLittlePointGeoJson)) { parser.nextToken(); - ElasticsearchGeoAssertions.assertValidException(parser, ElasticsearchParseException.class); + ElasticsearchGeoAssertions.assertValidException(parser, OpenSearchParseException.class); assertNull(parser.nextToken()); } @@ -1392,7 +1392,7 @@ public void testParseInvalidShapes() throws IOException { try (XContentParser parser = createParser(emptyPointGeoJson)) { parser.nextToken(); - ElasticsearchGeoAssertions.assertValidException(parser, ElasticsearchParseException.class); + ElasticsearchGeoAssertions.assertValidException(parser, OpenSearchParseException.class); assertNull(parser.nextToken()); } } @@ -1418,7 +1418,7 @@ public void testParseInvalidGeometryCollectionShapes() throws IOException { parser.nextToken(); // foo parser.nextToken(); // start object parser.nextToken(); // start object - ElasticsearchGeoAssertions.assertValidException(parser, ElasticsearchParseException.class); + ElasticsearchGeoAssertions.assertValidException(parser, OpenSearchParseException.class); assertEquals(XContentParser.Token.END_OBJECT, parser.nextToken()); // end of the document assertNull(parser.nextToken()); // no more elements afterwards } diff --git a/server/src/test/java/org/elasticsearch/common/geo/GeoWKTShapeParserTests.java b/server/src/test/java/org/elasticsearch/common/geo/GeoWKTShapeParserTests.java index b345e81c2d505..1f45f2e9036a2 100644 --- a/server/src/test/java/org/elasticsearch/common/geo/GeoWKTShapeParserTests.java +++ b/server/src/test/java/org/elasticsearch/common/geo/GeoWKTShapeParserTests.java @@ -20,7 +20,7 @@ import org.apache.lucene.geo.GeoTestUtil; import org.elasticsearch.OpenSearchException; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.Version; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.common.UUIDs; @@ -101,7 +101,7 @@ private void assertExpected(Object expected, ShapeBuilder builder, bool private void assertMalformed(ShapeBuilder builder) throws IOException { XContentBuilder xContentBuilder = toWKTContent(builder, true); - assertValidException(xContentBuilder, ElasticsearchParseException.class); + assertValidException(xContentBuilder, OpenSearchParseException.class); } @Override @@ -319,7 +319,7 @@ public void testParseMixedDimensionPolyWithHole() throws IOException, ParseExcep (GeoShapeFieldMapper) (new GeoShapeFieldMapper.Builder("test").ignoreZValue(false).build(mockBuilderContext)); // test store z disabled - ElasticsearchParseException e = expectThrows(ElasticsearchParseException.class, + OpenSearchParseException e = expectThrows(OpenSearchParseException.class, () -> ShapeParser.parse(parser, mapperBuilder)); assertThat(e, hasToString(containsString("but [ignore_z_value] parameter is [false]"))); } @@ -407,7 +407,7 @@ public void testParseOpenPolygon() throws IOException { Mapper.BuilderContext mockBuilderContext = new Mapper.BuilderContext(indexSettings, new ContentPath()); final LegacyGeoShapeFieldMapper defaultMapperBuilder = (LegacyGeoShapeFieldMapper)(new LegacyGeoShapeFieldMapper.Builder("test").coerce(false).build(mockBuilderContext)); - ElasticsearchParseException exception = expectThrows(ElasticsearchParseException.class, + OpenSearchParseException exception = expectThrows(OpenSearchParseException.class, () -> ShapeParser.parse(parser, defaultMapperBuilder)); assertEquals("invalid LinearRing found (coordinates are not closed)", exception.getMessage()); @@ -438,7 +438,7 @@ public void testMalformedWKT() throws IOException { // malformed points in a polygon is a common typo String malformedWKT = "POLYGON ((100, 5) (100, 10) (90, 10), (90, 5), (100, 5)"; XContentBuilder builder = XContentFactory.jsonBuilder().value(malformedWKT); - assertValidException(builder, ElasticsearchParseException.class); + assertValidException(builder, OpenSearchParseException.class); } @Override @@ -479,7 +479,7 @@ public void testUnexpectedShapeException() throws IOException { XContentBuilder builder = toWKTContent(new PointBuilder(-1, 2), false); XContentParser parser = createParser(builder); parser.nextToken(); - ElasticsearchParseException e = expectThrows(ElasticsearchParseException.class, + OpenSearchParseException e = expectThrows(OpenSearchParseException.class, () -> GeoWKTParser.parseExpectedType(parser, GeoShapeType.POLYGON)); assertThat(e, hasToString(containsString("Expected geometry type [polygon] but found [point]"))); } diff --git a/server/src/test/java/org/elasticsearch/common/geo/GeometryParserTests.java b/server/src/test/java/org/elasticsearch/common/geo/GeometryParserTests.java index 1503c6b5b81a7..9bc216deecb15 100644 --- a/server/src/test/java/org/elasticsearch/common/geo/GeometryParserTests.java +++ b/server/src/test/java/org/elasticsearch/common/geo/GeometryParserTests.java @@ -19,7 +19,7 @@ package org.elasticsearch.common.geo; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.common.Strings; import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.XContentBuilder; @@ -174,7 +174,7 @@ public void testUnsupportedValueParsing() throws Exception { parser.nextToken(); // Start object parser.nextToken(); // Field Name parser.nextToken(); // Field Value - ElasticsearchParseException ex = expectThrows(ElasticsearchParseException.class, + OpenSearchParseException ex = expectThrows(OpenSearchParseException.class, () -> new GeometryParser(true, randomBoolean(), randomBoolean()).parse(parser)); assertEquals("shape must be an object consisting of type and coordinates", ex.getMessage()); } @@ -224,7 +224,7 @@ public void testBasics() { Arrays.asList(expectedPoint, expectedPoint, expectedPoint, expectedPoint, expectedLine, expectedPolygon) ) ); - expectThrows(ElasticsearchParseException.class, () -> testBasics(parser, "not a geometry", null)); + expectThrows(OpenSearchParseException.class, () -> testBasics(parser, "not a geometry", null)); } private void testBasics(GeometryParser parser, Object value, Geometry expected) { diff --git a/server/src/test/java/org/elasticsearch/common/joda/JavaJodaTimeDuellingTests.java b/server/src/test/java/org/elasticsearch/common/joda/JavaJodaTimeDuellingTests.java index 094affb08b79b..2fdaec580337c 100644 --- a/server/src/test/java/org/elasticsearch/common/joda/JavaJodaTimeDuellingTests.java +++ b/server/src/test/java/org/elasticsearch/common/joda/JavaJodaTimeDuellingTests.java @@ -19,7 +19,7 @@ package org.elasticsearch.common.joda; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.bootstrap.JavaVersion; import org.elasticsearch.common.time.DateFormatter; import org.elasticsearch.common.time.DateFormatters; @@ -127,12 +127,12 @@ public void testExceptionWhenCompositeParsingFailsDateMath(){ //both patterns fail parsing the input text due to only 2 digits of millis. Hence full text was not parsed. String pattern = "yyyy-MM-dd'T'HH:mm:ss||yyyy-MM-dd'T'HH:mm:ss.SS"; String text = "2014-06-06T12:01:02.123"; - ElasticsearchParseException e1 = expectThrows(ElasticsearchParseException.class, + OpenSearchParseException e1 = expectThrows(OpenSearchParseException.class, () -> dateMathToMillis(text, DateFormatter.forPattern(pattern))); assertThat(e1.getMessage(), containsString(pattern)); assertThat(e1.getMessage(), containsString(text)); - ElasticsearchParseException e2 = expectThrows(ElasticsearchParseException.class, + OpenSearchParseException e2 = expectThrows(OpenSearchParseException.class, () -> dateMathToMillis(text, Joda.forPattern(pattern))); assertThat(e2.getMessage(), containsString(pattern)); assertThat(e2.getMessage(), containsString(text)); diff --git a/server/src/test/java/org/elasticsearch/common/joda/JodaDateMathParserTests.java b/server/src/test/java/org/elasticsearch/common/joda/JodaDateMathParserTests.java index fa5272955cf41..a316c9584a6c9 100644 --- a/server/src/test/java/org/elasticsearch/common/joda/JodaDateMathParserTests.java +++ b/server/src/test/java/org/elasticsearch/common/joda/JodaDateMathParserTests.java @@ -19,7 +19,7 @@ package org.elasticsearch.common.joda; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.common.time.DateFormatter; import org.elasticsearch.common.time.DateMathParser; import org.elasticsearch.test.ESTestCase; @@ -295,7 +295,7 @@ void assertParseException(String msg, String date, String exc) { try { parser.parse(date, () -> 0); fail("Date: " + date + "\n" + msg); - } catch (ElasticsearchParseException e) { + } catch (OpenSearchParseException e) { assertThat(e.getMessage().contains(exc), equalTo(true)); } } @@ -329,8 +329,8 @@ public void testThatUnixTimestampMayNotHaveTimeZone() { JodaDateMathParser parser = new JodaDateMathParser(Joda.forPattern("epoch_millis")); try { parser.parse("1234567890123", () -> 42, false, ZoneId.of("CET")); - fail("Expected ElasticsearchParseException"); - } catch(ElasticsearchParseException e) { + fail("Expected OpenSearchParseException"); + } catch(OpenSearchParseException e) { assertThat(e.getMessage(), containsString("failed to parse date field")); assertThat(e.getMessage(), containsString("with format [epoch_millis]")); } diff --git a/server/src/test/java/org/elasticsearch/common/settings/SettingsTests.java b/server/src/test/java/org/elasticsearch/common/settings/SettingsTests.java index 71bacca70c77b..6beb745381f47 100644 --- a/server/src/test/java/org/elasticsearch/common/settings/SettingsTests.java +++ b/server/src/test/java/org/elasticsearch/common/settings/SettingsTests.java @@ -19,7 +19,7 @@ package org.elasticsearch.common.settings; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.Version; import org.elasticsearch.common.Strings; import org.elasticsearch.common.bytes.BytesReference; @@ -613,7 +613,7 @@ public void testYamlLegacyList() throws IOException { public void testIndentation() throws Exception { String yaml = "/org/elasticsearch/common/settings/loader/indentation-settings.yml"; - ElasticsearchParseException e = expectThrows(ElasticsearchParseException.class, () -> { + OpenSearchParseException e = expectThrows(OpenSearchParseException.class, () -> { Settings.builder().loadFromStream(yaml, getClass().getResourceAsStream(yaml), false); }); assertTrue(e.getMessage(), e.getMessage().contains("malformed")); @@ -621,7 +621,7 @@ public void testIndentation() throws Exception { public void testIndentationWithExplicitDocumentStart() throws Exception { String yaml = "/org/elasticsearch/common/settings/loader/indentation-with-explicit-document-start-settings.yml"; - ElasticsearchParseException e = expectThrows(ElasticsearchParseException.class, () -> { + OpenSearchParseException e = expectThrows(OpenSearchParseException.class, () -> { Settings.builder().loadFromStream(yaml, getClass().getResourceAsStream(yaml), false); }); assertTrue(e.getMessage(), e.getMessage().contains("malformed")); @@ -631,7 +631,7 @@ public void testIndentationWithExplicitDocumentStart() throws Exception { public void testMissingValue() throws Exception { Path tmp = createTempFile("test", ".yaml"); Files.write(tmp, Collections.singletonList("foo: # missing value\n"), StandardCharsets.UTF_8); - ElasticsearchParseException e = expectThrows(ElasticsearchParseException.class, () -> { + OpenSearchParseException e = expectThrows(OpenSearchParseException.class, () -> { Settings.builder().loadFromPath(tmp); }); assertTrue( diff --git a/server/src/test/java/org/elasticsearch/common/time/JavaDateMathParserTests.java b/server/src/test/java/org/elasticsearch/common/time/JavaDateMathParserTests.java index d74759d539650..8e43598f6c74b 100644 --- a/server/src/test/java/org/elasticsearch/common/time/JavaDateMathParserTests.java +++ b/server/src/test/java/org/elasticsearch/common/time/JavaDateMathParserTests.java @@ -19,7 +19,7 @@ package org.elasticsearch.common.time; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.bootstrap.JavaVersion; import org.elasticsearch.test.ESTestCase; @@ -332,7 +332,7 @@ public void testTimestamps() { } void assertParseException(String msg, String date, String exc) { - ElasticsearchParseException e = expectThrows(ElasticsearchParseException.class, () -> parser.parse(date, () -> 0)); + OpenSearchParseException e = expectThrows(OpenSearchParseException.class, () -> parser.parse(date, () -> 0)); assertThat(msg, e.getMessage(), containsString(exc)); } diff --git a/server/src/test/java/org/elasticsearch/common/unit/ByteSizeValueTests.java b/server/src/test/java/org/elasticsearch/common/unit/ByteSizeValueTests.java index 81c0c796ce17f..d3e1887af0807 100644 --- a/server/src/test/java/org/elasticsearch/common/unit/ByteSizeValueTests.java +++ b/server/src/test/java/org/elasticsearch/common/unit/ByteSizeValueTests.java @@ -19,7 +19,7 @@ package org.elasticsearch.common.unit; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.common.io.stream.Writeable.Reader; import org.elasticsearch.test.AbstractWireSerializingTestCase; import org.hamcrest.MatcherAssert; @@ -129,29 +129,29 @@ public void testParsing() { } public void testFailOnMissingUnits() { - Exception e = expectThrows(ElasticsearchParseException.class, () -> ByteSizeValue.parseBytesSizeValue("23", "test")); + Exception e = expectThrows(OpenSearchParseException.class, () -> ByteSizeValue.parseBytesSizeValue("23", "test")); assertThat(e.getMessage(), containsString("failed to parse setting [test]")); } public void testFailOnUnknownUnits() { - Exception e = expectThrows(ElasticsearchParseException.class, () -> ByteSizeValue.parseBytesSizeValue("23jw", "test")); + Exception e = expectThrows(OpenSearchParseException.class, () -> ByteSizeValue.parseBytesSizeValue("23jw", "test")); assertThat(e.getMessage(), containsString("failed to parse setting [test]")); } public void testFailOnEmptyParsing() { - Exception e = expectThrows(ElasticsearchParseException.class, + Exception e = expectThrows(OpenSearchParseException.class, () -> assertThat(ByteSizeValue.parseBytesSizeValue("", "emptyParsing").toString(), is("23kb"))); assertThat(e.getMessage(), containsString("failed to parse setting [emptyParsing]")); } public void testFailOnEmptyNumberParsing() { - Exception e = expectThrows(ElasticsearchParseException.class, + Exception e = expectThrows(OpenSearchParseException.class, () -> assertThat(ByteSizeValue.parseBytesSizeValue("g", "emptyNumberParsing").toString(), is("23b"))); assertThat(e.getMessage(), containsString("failed to parse [g]")); } public void testNoDotsAllowed() { - Exception e = expectThrows(ElasticsearchParseException.class, () -> ByteSizeValue.parseBytesSizeValue("42b.", null, "test")); + Exception e = expectThrows(OpenSearchParseException.class, () -> ByteSizeValue.parseBytesSizeValue("42b.", null, "test")); assertThat(e.getMessage(), containsString("failed to parse setting [test]")); } @@ -272,7 +272,7 @@ public void testParse() { } public void testParseInvalidValue() { - ElasticsearchParseException exception = expectThrows(ElasticsearchParseException.class, + OpenSearchParseException exception = expectThrows(OpenSearchParseException.class, () -> ByteSizeValue.parseBytesSizeValue("-6mb", "test_setting")); assertEquals("failed to parse setting [test_setting] with value [-6mb] as a size in bytes", exception.getMessage()); assertNotNull(exception.getCause()); @@ -295,12 +295,12 @@ public void testParseSpecialValues() throws IOException { } public void testParseInvalidNumber() throws IOException { - ElasticsearchParseException exception = expectThrows(ElasticsearchParseException.class, + OpenSearchParseException exception = expectThrows(OpenSearchParseException.class, () -> ByteSizeValue.parseBytesSizeValue("notANumber", "test")); assertEquals("failed to parse setting [test] with value [notANumber] as a size in bytes: unit is missing or unrecognized", exception.getMessage()); - exception = expectThrows(ElasticsearchParseException.class, () -> ByteSizeValue.parseBytesSizeValue("notANumberMB", "test")); + exception = expectThrows(OpenSearchParseException.class, () -> ByteSizeValue.parseBytesSizeValue("notANumberMB", "test")); assertEquals("failed to parse [notANumberMB]", exception.getMessage()); } diff --git a/server/src/test/java/org/elasticsearch/common/unit/RatioValueTests.java b/server/src/test/java/org/elasticsearch/common/unit/RatioValueTests.java index e918a579df000..79207f608a8c5 100644 --- a/server/src/test/java/org/elasticsearch/common/unit/RatioValueTests.java +++ b/server/src/test/java/org/elasticsearch/common/unit/RatioValueTests.java @@ -19,7 +19,7 @@ package org.elasticsearch.common.unit; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.test.ESTestCase; import static org.hamcrest.Matchers.is; @@ -58,7 +58,7 @@ public void testInvalidRatio(String r) { try { RatioValue.parseRatioValue(r); fail("Value: [" + r + "] should be an invalid ratio"); - } catch (ElasticsearchParseException e) { + } catch (OpenSearchParseException e) { // success } } diff --git a/server/src/test/java/org/elasticsearch/index/mapper/RangeFieldTypeTests.java b/server/src/test/java/org/elasticsearch/index/mapper/RangeFieldTypeTests.java index 4086fe4f3a4e5..d2a1095e456d3 100644 --- a/server/src/test/java/org/elasticsearch/index/mapper/RangeFieldTypeTests.java +++ b/server/src/test/java/org/elasticsearch/index/mapper/RangeFieldTypeTests.java @@ -30,7 +30,7 @@ import org.apache.lucene.search.MatchNoDocsQuery; import org.apache.lucene.search.Query; import org.apache.lucene.util.BytesRef; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.Version; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.common.geo.ShapeRelation; @@ -226,7 +226,7 @@ public void testDateRangeQueryUsingMappingFormat() { final String from = "2016-15-06T15:29:50+08:00"; final String to = "2016-16-06T15:29:50+08:00"; - ElasticsearchParseException ex = expectThrows(ElasticsearchParseException.class, + OpenSearchParseException ex = expectThrows(OpenSearchParseException.class, () -> strict.rangeQuery(from, to, true, true, relation, null, null, context)); assertThat(ex.getMessage(), containsString("failed to parse date field [2016-15-06T15:29:50+08:00] with format [strict_date_optional_time||epoch_millis]") diff --git a/server/src/test/java/org/elasticsearch/index/query/FuzzyQueryBuilderTests.java b/server/src/test/java/org/elasticsearch/index/query/FuzzyQueryBuilderTests.java index 26855a783c327..617951033fba6 100644 --- a/server/src/test/java/org/elasticsearch/index/query/FuzzyQueryBuilderTests.java +++ b/server/src/test/java/org/elasticsearch/index/query/FuzzyQueryBuilderTests.java @@ -23,7 +23,7 @@ import org.apache.lucene.search.BoostQuery; import org.apache.lucene.search.FuzzyQuery; import org.apache.lucene.search.Query; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.common.ParsingException; import org.elasticsearch.common.unit.Fuzziness; import org.elasticsearch.test.AbstractQueryTestCase; @@ -158,7 +158,7 @@ public void testToQueryWithStringFieldDefinedWrongFuzziness() throws IOException " }\n" + " }\n" + "}"; - ElasticsearchParseException e = expectThrows(ElasticsearchParseException.class, + OpenSearchParseException e = expectThrows(OpenSearchParseException.class, () -> parseQuery(queryMissingFuzzinessUpLimit).toQuery(createShardContext())); String msg = "failed to find low and high distance values"; assertTrue(e.getMessage() + " didn't contain: " + msg + " but: " + e.getMessage(), e.getMessage().contains(msg)); @@ -189,7 +189,7 @@ public void testToQueryWithStringFieldDefinedWrongFuzziness() throws IOException " }\n" + " }\n" + "}"; - e = expectThrows(ElasticsearchParseException.class, + e = expectThrows(OpenSearchParseException.class, () -> parseQuery(queryMissingFuzzinessUpLimit2).toQuery(createShardContext())); assertTrue(e.getMessage() + " didn't contain: " + msg + " but: " + e.getMessage(), e.getMessage().contains(msg)); @@ -203,7 +203,7 @@ public void testToQueryWithStringFieldDefinedWrongFuzziness() throws IOException " }\n" + " }\n" + "}"; - e = expectThrows(ElasticsearchParseException.class, + e = expectThrows(OpenSearchParseException.class, () -> parseQuery(queryMissingFuzzinessLowLimit).toQuery(createShardContext())); msg = "failed to parse [AUTO:,5] as a \"auto:int,int\""; assertTrue(e.getMessage() + " didn't contain: " + msg + " but: " + e.getMessage(), e.getMessage().contains(msg)); diff --git a/server/src/test/java/org/elasticsearch/index/query/GeoBoundingBoxQueryBuilderTests.java b/server/src/test/java/org/elasticsearch/index/query/GeoBoundingBoxQueryBuilderTests.java index 4b49746c79511..fa1974b683002 100644 --- a/server/src/test/java/org/elasticsearch/index/query/GeoBoundingBoxQueryBuilderTests.java +++ b/server/src/test/java/org/elasticsearch/index/query/GeoBoundingBoxQueryBuilderTests.java @@ -24,7 +24,7 @@ import org.apache.lucene.search.IndexOrDocValuesQuery; import org.apache.lucene.search.MatchNoDocsQuery; import org.apache.lucene.search.Query; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.common.geo.GeoPoint; import org.elasticsearch.common.geo.GeoUtils; import org.elasticsearch.index.mapper.MappedFieldType; @@ -496,7 +496,7 @@ public void testMalformedGeohashes() { " }\n" + "}"; - ElasticsearchParseException e1 = expectThrows(ElasticsearchParseException.class, () -> parseQuery(jsonGeohashAndWkt)); + OpenSearchParseException e1 = expectThrows(OpenSearchParseException.class, () -> parseQuery(jsonGeohashAndWkt)); assertThat(e1.getMessage(), containsString("Conflicting definition found using well-known text and explicit corners.")); } diff --git a/server/src/test/java/org/elasticsearch/index/query/RangeQueryBuilderTests.java b/server/src/test/java/org/elasticsearch/index/query/RangeQueryBuilderTests.java index 7d1cc8f01997b..577293a9765a7 100644 --- a/server/src/test/java/org/elasticsearch/index/query/RangeQueryBuilderTests.java +++ b/server/src/test/java/org/elasticsearch/index/query/RangeQueryBuilderTests.java @@ -31,7 +31,7 @@ import org.apache.lucene.search.Query; import org.apache.lucene.search.TermQuery; import org.apache.lucene.search.TermRangeQuery; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.Version; import org.elasticsearch.common.ParsingException; import org.elasticsearch.common.geo.ShapeRelation; @@ -290,7 +290,7 @@ public void testDateRangeQueryFormat() throws IOException { " }\n" + " }\n" + "}"; - expectThrows(ElasticsearchParseException.class, () -> parseQuery(invalidQuery).toQuery(createShardContext())); + expectThrows(OpenSearchParseException.class, () -> parseQuery(invalidQuery).toQuery(createShardContext())); } public void testDateRangeBoundaries() throws IOException { diff --git a/server/src/test/java/org/elasticsearch/index/search/geo/GeoPointParsingTests.java b/server/src/test/java/org/elasticsearch/index/search/geo/GeoPointParsingTests.java index 13433d26c2a5a..f9f7ccc507e85 100644 --- a/server/src/test/java/org/elasticsearch/index/search/geo/GeoPointParsingTests.java +++ b/server/src/test/java/org/elasticsearch/index/search/geo/GeoPointParsingTests.java @@ -19,7 +19,7 @@ package org.elasticsearch.index.search.geo; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.geo.GeoPoint; import org.elasticsearch.common.geo.GeoUtils; @@ -63,13 +63,13 @@ public void testGeoPointReset() throws IOException { public void testParseWktInvalid() { GeoPoint point = new GeoPoint(0, 0); Exception e = expectThrows( - ElasticsearchParseException.class, + OpenSearchParseException.class, () -> point.resetFromString("NOT A POINT(1 2)") ); assertEquals("Invalid WKT format", e.getMessage()); Exception e2 = expectThrows( - ElasticsearchParseException.class, + OpenSearchParseException.class, () -> point.resetFromString("MULTIPOINT(1 2, 3 4)") ); assertEquals("[geo_point] supports only POINT among WKT primitives, but found MULTIPOINT", e2.getMessage()); @@ -125,12 +125,12 @@ public void testInvalidPointEmbeddedObject() throws IOException { try (XContentParser parser = createParser(JsonXContent.jsonXContent, BytesReference.bytes(content))) { parser.nextToken(); - Exception e = expectThrows(ElasticsearchParseException.class, () -> GeoUtils.parseGeoPoint(parser)); + Exception e = expectThrows(OpenSearchParseException.class, () -> GeoUtils.parseGeoPoint(parser)); assertThat(e.getMessage(), is("field must be either [lat], [lon] or [geohash]")); } try (XContentParser parser2 = createParser(JsonXContent.jsonXContent, BytesReference.bytes(content))) { parser2.nextToken(); - Exception e = expectThrows(ElasticsearchParseException.class, () -> + Exception e = expectThrows(OpenSearchParseException.class, () -> GeoUtils.parseGeoPoint(toObject(parser2), randomBoolean())); assertThat(e.getMessage(), is("field must be either [lat], [lon] or [geohash]")); } @@ -144,12 +144,12 @@ public void testInvalidPointLatHashMix() throws IOException { try (XContentParser parser = createParser(JsonXContent.jsonXContent, BytesReference.bytes(content))) { parser.nextToken(); - Exception e = expectThrows(ElasticsearchParseException.class, () -> GeoUtils.parseGeoPoint(parser)); + Exception e = expectThrows(OpenSearchParseException.class, () -> GeoUtils.parseGeoPoint(parser)); assertThat(e.getMessage(), is("field must be either lat/lon or geohash")); } try (XContentParser parser2 = createParser(JsonXContent.jsonXContent, BytesReference.bytes(content))) { parser2.nextToken(); - Exception e = expectThrows(ElasticsearchParseException.class, () -> + Exception e = expectThrows(OpenSearchParseException.class, () -> GeoUtils.parseGeoPoint(toObject(parser2), randomBoolean())); assertThat(e.getMessage(), is("field must be either lat/lon or geohash")); } @@ -164,12 +164,12 @@ public void testInvalidPointLonHashMix() throws IOException { try (XContentParser parser = createParser(JsonXContent.jsonXContent, BytesReference.bytes(content))) { parser.nextToken(); - Exception e = expectThrows(ElasticsearchParseException.class, () -> GeoUtils.parseGeoPoint(parser)); + Exception e = expectThrows(OpenSearchParseException.class, () -> GeoUtils.parseGeoPoint(parser)); assertThat(e.getMessage(), is("field must be either lat/lon or geohash")); } try (XContentParser parser2 = createParser(JsonXContent.jsonXContent, BytesReference.bytes(content))) { parser2.nextToken(); - Exception e = expectThrows(ElasticsearchParseException.class, () -> + Exception e = expectThrows(OpenSearchParseException.class, () -> GeoUtils.parseGeoPoint(toObject(parser2), randomBoolean())); assertThat(e.getMessage(), is("field must be either lat/lon or geohash")); } @@ -183,13 +183,13 @@ public void testInvalidField() throws IOException { try (XContentParser parser = createParser(JsonXContent.jsonXContent, BytesReference.bytes(content))) { parser.nextToken(); - Exception e = expectThrows(ElasticsearchParseException.class, () -> GeoUtils.parseGeoPoint(parser)); + Exception e = expectThrows(OpenSearchParseException.class, () -> GeoUtils.parseGeoPoint(parser)); assertThat(e.getMessage(), is("field must be either [lat], [lon] or [geohash]")); } try (XContentParser parser2 = createParser(JsonXContent.jsonXContent, BytesReference.bytes(content))) { parser2.nextToken(); - Exception e = expectThrows(ElasticsearchParseException.class, () -> + Exception e = expectThrows(OpenSearchParseException.class, () -> GeoUtils.parseGeoPoint(toObject(parser2), randomBoolean())); assertThat(e.getMessage(), is("field must be either [lat], [lon] or [geohash]")); } @@ -204,7 +204,7 @@ public void testInvalidGeoHash() throws IOException { try (XContentParser parser = createParser(JsonXContent.jsonXContent, BytesReference.bytes(content))) { parser.nextToken(); - Exception e = expectThrows(ElasticsearchParseException.class, () -> GeoUtils.parseGeoPoint(parser)); + Exception e = expectThrows(OpenSearchParseException.class, () -> GeoUtils.parseGeoPoint(parser)); assertThat(e.getMessage(), is("unsupported symbol [!] in geohash [!!!!]")); } } diff --git a/server/src/test/java/org/elasticsearch/index/search/geo/GeoUtilsTests.java b/server/src/test/java/org/elasticsearch/index/search/geo/GeoUtilsTests.java index 88e0b9fec123f..aa88000e72013 100644 --- a/server/src/test/java/org/elasticsearch/index/search/geo/GeoUtilsTests.java +++ b/server/src/test/java/org/elasticsearch/index/search/geo/GeoUtilsTests.java @@ -22,7 +22,7 @@ import org.apache.lucene.spatial.prefix.tree.Cell; import org.apache.lucene.spatial.prefix.tree.GeohashPrefixTree; import org.apache.lucene.spatial.prefix.tree.QuadPrefixTree; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.common.geo.GeoPoint; import org.elasticsearch.common.geo.GeoUtils; import org.elasticsearch.common.xcontent.XContentBuilder; @@ -438,7 +438,7 @@ public void testParseGeoPointStringZValueError() throws IOException { while (parser.currentToken() != Token.VALUE_STRING) { parser.nextToken(); } - Exception e = expectThrows(ElasticsearchParseException.class, + Exception e = expectThrows(OpenSearchParseException.class, () -> GeoUtils.parseGeoPoint(parser, new GeoPoint(), false)); assertThat(e.getMessage(), containsString("but [ignore_z_value] parameter is [false]")); } @@ -451,7 +451,7 @@ public void testParseGeoPointArrayZValueError() throws IOException { XContentBuilder json = jsonBuilder().startArray().value(lat).value(lon).value(alt).endArray(); try (XContentParser parser = createParser(json)) { parser.nextToken(); - Exception e = expectThrows(ElasticsearchParseException.class, + Exception e = expectThrows(OpenSearchParseException.class, () -> GeoUtils.parseGeoPoint(parser, new GeoPoint(), false)); assertThat(e.getMessage(), containsString("but [ignore_z_value] parameter is [false]")); assertThat(parser.currentToken(), is(Token.END_ARRAY)); @@ -491,7 +491,7 @@ public void testParseGeoPointGeohashWrongType() throws IOException { XContentBuilder json = jsonBuilder().startObject().field("geohash", 1.0).endObject(); try (XContentParser parser = createParser(json)) { parser.nextToken(); - Exception e = expectThrows(ElasticsearchParseException.class, () -> GeoUtils.parseGeoPoint(parser)); + Exception e = expectThrows(OpenSearchParseException.class, () -> GeoUtils.parseGeoPoint(parser)); assertThat(e.getMessage(), containsString("geohash must be a string")); assertThat(parser.currentToken(), is(Token.END_OBJECT)); assertNull(parser.nextToken()); @@ -503,7 +503,7 @@ public void testParseGeoPointLatNoLon() throws IOException { XContentBuilder json = jsonBuilder().startObject().field("lat", lat).endObject(); try (XContentParser parser = createParser(json)) { parser.nextToken(); - Exception e = expectThrows(ElasticsearchParseException.class, () -> GeoUtils.parseGeoPoint(parser)); + Exception e = expectThrows(OpenSearchParseException.class, () -> GeoUtils.parseGeoPoint(parser)); assertThat(e.getMessage(), is("field [lon] missing")); assertThat(parser.currentToken(), is(Token.END_OBJECT)); assertNull(parser.nextToken()); @@ -515,7 +515,7 @@ public void testParseGeoPointLonNoLat() throws IOException { XContentBuilder json = jsonBuilder().startObject().field("lon", lon).endObject(); try (XContentParser parser = createParser(json)) { parser.nextToken(); - Exception e = expectThrows(ElasticsearchParseException.class, () -> GeoUtils.parseGeoPoint(parser)); + Exception e = expectThrows(OpenSearchParseException.class, () -> GeoUtils.parseGeoPoint(parser)); assertThat(e.getMessage(), is("field [lat] missing")); assertThat(parser.currentToken(), is(Token.END_OBJECT)); assertNull(parser.nextToken()); @@ -527,7 +527,7 @@ public void testParseGeoPointLonWrongType() throws IOException { XContentBuilder json = jsonBuilder().startObject().field("lat", lat).field("lon", false).endObject(); try (XContentParser parser = createParser(json)) { parser.nextToken(); - Exception e = expectThrows(ElasticsearchParseException.class, () -> GeoUtils.parseGeoPoint(parser)); + Exception e = expectThrows(OpenSearchParseException.class, () -> GeoUtils.parseGeoPoint(parser)); assertThat(e.getMessage(), is("longitude must be a number")); assertThat(parser.currentToken(), is(Token.END_OBJECT)); assertNull(parser.nextToken()); @@ -539,7 +539,7 @@ public void testParseGeoPointLatWrongType() throws IOException { XContentBuilder json = jsonBuilder().startObject().field("lat", false).field("lon", lon).endObject(); try (XContentParser parser = createParser(json)) { parser.nextToken(); - Exception e = expectThrows(ElasticsearchParseException.class, () -> GeoUtils.parseGeoPoint(parser)); + Exception e = expectThrows(OpenSearchParseException.class, () -> GeoUtils.parseGeoPoint(parser)); assertThat(e.getMessage(), is("latitude must be a number")); assertThat(parser.currentToken(), is(Token.END_OBJECT)); assertNull(parser.nextToken()); @@ -553,7 +553,7 @@ public void testParseGeoPointExtraField() throws IOException { .field("lat", lat).field("lon", lon).field("foo", true).endObject(); try (XContentParser parser = createParser(json)) { parser.nextToken(); - Exception e = expectThrows(ElasticsearchParseException.class, () -> GeoUtils.parseGeoPoint(parser)); + Exception e = expectThrows(OpenSearchParseException.class, () -> GeoUtils.parseGeoPoint(parser)); assertThat(e.getMessage(), is("field must be either [lat], [lon] or [geohash]")); } } @@ -566,7 +566,7 @@ public void testParseGeoPointLonLatGeoHash() throws IOException { .field("lat", lat).field("lon", lon).field("geohash", geohash).endObject(); try (XContentParser parser = createParser(json)) { parser.nextToken(); - Exception e = expectThrows(ElasticsearchParseException.class, () -> GeoUtils.parseGeoPoint(parser)); + Exception e = expectThrows(OpenSearchParseException.class, () -> GeoUtils.parseGeoPoint(parser)); assertThat(e.getMessage(), containsString("field must be either lat/lon or geohash")); } } @@ -580,7 +580,7 @@ public void testParseGeoPointArrayTooManyValues() throws IOException { while (parser.currentToken() != Token.START_ARRAY) { parser.nextToken(); } - Exception e = expectThrows(ElasticsearchParseException.class, () -> GeoUtils.parseGeoPoint(parser)); + Exception e = expectThrows(OpenSearchParseException.class, () -> GeoUtils.parseGeoPoint(parser)); assertThat(e.getMessage(), is("Exception parsing coordinates: found Z value [0.0] but [ignore_z_value] parameter is [false]")); } @@ -609,7 +609,7 @@ public void testParseGeoPointArrayWrongType() throws IOException { while (parser.currentToken() != Token.START_ARRAY) { parser.nextToken(); } - Exception e = expectThrows(ElasticsearchParseException.class, () -> GeoUtils.parseGeoPoint(parser)); + Exception e = expectThrows(OpenSearchParseException.class, () -> GeoUtils.parseGeoPoint(parser)); assertThat(e.getMessage(), is("numeric value expected")); assertThat(parser.currentToken(), is(Token.END_ARRAY)); assertThat(parser.nextToken(), is(Token.END_OBJECT)); @@ -623,7 +623,7 @@ public void testParseGeoPointInvalidType() throws IOException { while (parser.currentToken() != Token.VALUE_NUMBER) { parser.nextToken(); } - Exception e = expectThrows(ElasticsearchParseException.class, () -> GeoUtils.parseGeoPoint(parser)); + Exception e = expectThrows(OpenSearchParseException.class, () -> GeoUtils.parseGeoPoint(parser)); assertThat(e.getMessage(), is("geo_point expected")); } } diff --git a/server/src/test/java/org/elasticsearch/index/snapshots/blobstore/FileInfoTests.java b/server/src/test/java/org/elasticsearch/index/snapshots/blobstore/FileInfoTests.java index db79d02ea738a..66eadb14530e5 100644 --- a/server/src/test/java/org/elasticsearch/index/snapshots/blobstore/FileInfoTests.java +++ b/server/src/test/java/org/elasticsearch/index/snapshots/blobstore/FileInfoTests.java @@ -20,7 +20,7 @@ import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.Version; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.unit.ByteSizeValue; import org.elasticsearch.common.xcontent.ToXContent; @@ -136,7 +136,7 @@ public void testInvalidFieldsInFromXContent() throws IOException { parser.nextToken(); BlobStoreIndexShardSnapshot.FileInfo.fromXContent(parser); fail("Should have failed with [" + failure + "]"); - } catch (ElasticsearchParseException ex) { + } catch (OpenSearchParseException ex) { assertThat(ex.getMessage(), containsString(failure)); } } diff --git a/server/src/test/java/org/elasticsearch/ingest/ConfigurationUtilsTests.java b/server/src/test/java/org/elasticsearch/ingest/ConfigurationUtilsTests.java index 3eb6ada4e725d..7c1932ced014e 100644 --- a/server/src/test/java/org/elasticsearch/ingest/ConfigurationUtilsTests.java +++ b/server/src/test/java/org/elasticsearch/ingest/ConfigurationUtilsTests.java @@ -19,7 +19,7 @@ package org.elasticsearch.ingest; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.script.ScriptService; import org.elasticsearch.script.TemplateScript; import org.elasticsearch.test.ESTestCase; @@ -75,7 +75,7 @@ public void testReadStringProperty() { public void testReadStringPropertyInvalidType() { try { ConfigurationUtils.readStringProperty(null, null, config, "arr"); - } catch (ElasticsearchParseException e) { + } catch (OpenSearchParseException e) { assertThat(e.getMessage(), equalTo("[arr] property isn't a string, but of type [java.util.Arrays$ArrayList]")); } } @@ -93,7 +93,7 @@ public void testReadNullBooleanProperty() { public void testReadBooleanPropertyInvalidType() { try { ConfigurationUtils.readBooleanProperty(null, null, config, "arr", true); - } catch (ElasticsearchParseException e) { + } catch (OpenSearchParseException e) { assertThat(e.getMessage(), equalTo("[arr] property isn't a boolean, but of type [java.util.Arrays$ArrayList]")); } } @@ -108,7 +108,7 @@ public void testReadStringOrIntProperty() { public void testReadStringOrIntPropertyInvalidType() { try { ConfigurationUtils.readStringOrIntProperty(null, null, config, "arr", null); - } catch (ElasticsearchParseException e) { + } catch (OpenSearchParseException e) { assertThat(e.getMessage(), equalTo( "[arr] property isn't a string or int, but of type [java.util.Arrays$ArrayList]")); } @@ -135,7 +135,7 @@ public void testReadProcessors() throws Exception { unknownTaggedConfig.put("description", "my_description"); } config.add(Collections.singletonMap("unknown_processor", unknownTaggedConfig)); - ElasticsearchParseException e = expectThrows(ElasticsearchParseException.class, + OpenSearchParseException e = expectThrows(OpenSearchParseException.class, () -> ConfigurationUtils.readProcessorConfigs(config, scriptService, registry)); assertThat(e.getMessage(), equalTo("No processor type exists with name [unknown_processor]")); assertThat(e.getMetadata("es.processor_tag"), equalTo(Collections.singletonList("my_unknown"))); @@ -151,7 +151,7 @@ public void testReadProcessors() throws Exception { secondUnknownTaggedConfig.put("tag", "my_second_unknown"); config2.add(Collections.singletonMap("second_unknown_processor", secondUnknownTaggedConfig)); e = expectThrows( - ElasticsearchParseException.class, + OpenSearchParseException.class, () -> ConfigurationUtils.readProcessorConfigs(config2, scriptService, registry) ); assertThat(e.getMessage(), equalTo("No processor type exists with name [unknown_processor]")); @@ -160,8 +160,8 @@ public void testReadProcessors() throws Exception { assertThat(e.getMetadata("es.property_name"), is(nullValue())); assertThat(e.getSuppressed().length, equalTo(1)); - assertThat(e.getSuppressed()[0], instanceOf(ElasticsearchParseException.class)); - ElasticsearchParseException e2 = (ElasticsearchParseException) e.getSuppressed()[0]; + assertThat(e.getSuppressed()[0], instanceOf(OpenSearchParseException.class)); + OpenSearchParseException e2 = (OpenSearchParseException) e.getSuppressed()[0]; assertThat(e2.getMessage(), equalTo("No processor type exists with name [second_unknown_processor]")); assertThat(e2.getMetadata("es.processor_tag"), equalTo(Collections.singletonList("my_second_unknown"))); assertThat(e2.getMetadata("es.processor_type"), equalTo(Collections.singletonList("second_unknown_processor"))); @@ -220,7 +220,7 @@ public void testReadProcessorFromObjectOrMap() throws Exception { Object invalidConfig = 12L; - ElasticsearchParseException ex = expectThrows(ElasticsearchParseException.class, + OpenSearchParseException ex = expectThrows(OpenSearchParseException.class, () -> ConfigurationUtils.readProcessor(registry, scriptService, "unknown_processor", invalidConfig)); assertThat(ex.getMessage(), equalTo("property isn't a map, but of type [" + invalidConfig.getClass().getName() + "]")); } diff --git a/server/src/test/java/org/elasticsearch/ingest/IngestServiceTests.java b/server/src/test/java/org/elasticsearch/ingest/IngestServiceTests.java index 48ae26ead9109..81da3fe415a51 100644 --- a/server/src/test/java/org/elasticsearch/ingest/IngestServiceTests.java +++ b/server/src/test/java/org/elasticsearch/ingest/IngestServiceTests.java @@ -23,7 +23,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.lucene.util.SetOnce; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.ResourceNotFoundException; import org.elasticsearch.Version; import org.elasticsearch.action.DocWriteRequest; @@ -625,8 +625,8 @@ public void testValidate() throws Exception { ingestInfos.put(node1, new IngestInfo(Arrays.asList(new ProcessorInfo("set"), new ProcessorInfo("remove")))); ingestInfos.put(node2, new IngestInfo(Arrays.asList(new ProcessorInfo("set")))); - ElasticsearchParseException e = - expectThrows(ElasticsearchParseException.class, () -> ingestService.validatePipeline(ingestInfos, putRequest)); + OpenSearchParseException e = + expectThrows(OpenSearchParseException.class, () -> ingestService.validatePipeline(ingestInfos, putRequest)); assertEquals("Processor type [remove] is not installed on node [" + node2 + "]", e.getMessage()); assertEquals("remove", e.getMetadata("es.processor_type").get(0)); assertEquals("tag2", e.getMetadata("es.processor_tag").get(0)); diff --git a/server/src/test/java/org/elasticsearch/ingest/PipelineFactoryTests.java b/server/src/test/java/org/elasticsearch/ingest/PipelineFactoryTests.java index d6d7b4ffa816b..05f64374c853f 100644 --- a/server/src/test/java/org/elasticsearch/ingest/PipelineFactoryTests.java +++ b/server/src/test/java/org/elasticsearch/ingest/PipelineFactoryTests.java @@ -19,7 +19,7 @@ package org.elasticsearch.ingest; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.script.ScriptService; import org.elasticsearch.test.ESTestCase; @@ -69,7 +69,7 @@ public void testCreateWithNoProcessorsField() throws Exception { try { Pipeline.create("_id", pipelineConfig, Collections.emptyMap(), scriptService); fail("should fail, missing required [processors] field"); - } catch (ElasticsearchParseException e) { + } catch (OpenSearchParseException e) { assertThat(e.getMessage(), equalTo("[processors] required property is missing")); } } @@ -113,7 +113,7 @@ public void testCreateWithPipelineEmptyOnFailure() throws Exception { pipelineConfig.put(Pipeline.ON_FAILURE_KEY, Collections.emptyList()); Map processorRegistry = Collections.singletonMap("test", new TestProcessor.Factory()); Exception e = expectThrows( - ElasticsearchParseException.class, + OpenSearchParseException.class, () -> Pipeline.create("_id", pipelineConfig, processorRegistry, scriptService) ); assertThat(e.getMessage(), equalTo("pipeline [_id] cannot have an empty on_failure option defined")); @@ -128,7 +128,7 @@ public void testCreateWithPipelineEmptyOnFailureInProcessor() throws Exception { pipelineConfig.put(Pipeline.PROCESSORS_KEY, Collections.singletonList(Collections.singletonMap("test", processorConfig))); Map processorRegistry = Collections.singletonMap("test", new TestProcessor.Factory()); Exception e = expectThrows( - ElasticsearchParseException.class, + OpenSearchParseException.class, () -> Pipeline.create("_id", pipelineConfig, processorRegistry, scriptService) ); assertThat(e.getMessage(), equalTo("[on_failure] processors list cannot be empty")); @@ -166,7 +166,7 @@ public void testCreateUnusedProcessorOptions() throws Exception { pipelineConfig.put(Pipeline.PROCESSORS_KEY, Collections.singletonList(Collections.singletonMap("test", processorConfig))); Map processorRegistry = Collections.singletonMap("test", new TestProcessor.Factory()); Exception e = expectThrows( - ElasticsearchParseException.class, + OpenSearchParseException.class, () -> Pipeline.create("_id", pipelineConfig, processorRegistry, scriptService) ); assertThat(e.getMessage(), equalTo("processor [test] doesn't support one or more provided configuration parameters [unused]")); diff --git a/server/src/test/java/org/elasticsearch/repositories/RepositoryDataTests.java b/server/src/test/java/org/elasticsearch/repositories/RepositoryDataTests.java index 584956bbffcdf..e78a2a6bdcd98 100644 --- a/server/src/test/java/org/elasticsearch/repositories/RepositoryDataTests.java +++ b/server/src/test/java/org/elasticsearch/repositories/RepositoryDataTests.java @@ -19,7 +19,7 @@ package org.elasticsearch.repositories; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.Version; import org.elasticsearch.common.UUIDs; import org.elasticsearch.common.bytes.BytesReference; @@ -235,7 +235,7 @@ public void testIndexThatReferencesAnUnknownSnapshot() throws IOException { corruptedRepositoryData.snapshotsToXContent(corruptedBuilder, Version.CURRENT); try (XContentParser xParser = createParser(corruptedBuilder)) { - ElasticsearchParseException e = expectThrows(ElasticsearchParseException.class, () -> + OpenSearchParseException e = expectThrows(OpenSearchParseException.class, () -> RepositoryData.snapshotsFromXContent(xParser, corruptedRepositoryData.getGenId(), randomBoolean())); assertThat(e.getMessage(), equalTo("Detected a corrupted repository, index " + corruptedIndexId + " references an unknown " + "snapshot uuid [_does_not_exist]")); @@ -272,7 +272,7 @@ public void testIndexThatReferenceANullSnapshot() throws IOException { builder.endObject(); try (XContentParser xParser = createParser(builder)) { - ElasticsearchParseException e = expectThrows(ElasticsearchParseException.class, () -> + OpenSearchParseException e = expectThrows(OpenSearchParseException.class, () -> RepositoryData.snapshotsFromXContent(xParser, randomNonNegativeLong(), randomBoolean())); assertThat(e.getMessage(), equalTo("Detected a corrupted repository, " + "index [docs/_id] references an unknown snapshot uuid [null]")); diff --git a/server/src/test/java/org/elasticsearch/rest/RestRequestTests.java b/server/src/test/java/org/elasticsearch/rest/RestRequestTests.java index b0d9847c94732..af6d610954a14 100644 --- a/server/src/test/java/org/elasticsearch/rest/RestRequestTests.java +++ b/server/src/test/java/org/elasticsearch/rest/RestRequestTests.java @@ -19,7 +19,7 @@ package org.elasticsearch.rest; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.common.CheckedConsumer; import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.common.bytes.BytesReference; @@ -102,14 +102,14 @@ private void runConsumesContentTest( } public void testContentParser() throws IOException { - Exception e = expectThrows(ElasticsearchParseException.class, () -> + Exception e = expectThrows(OpenSearchParseException.class, () -> contentRestRequest("", emptyMap()).contentParser()); assertEquals("request body is required", e.getMessage()); - e = expectThrows(ElasticsearchParseException.class, () -> + e = expectThrows(OpenSearchParseException.class, () -> contentRestRequest("", singletonMap("source", "{}")).contentParser()); assertEquals("request body is required", e.getMessage()); assertEquals(emptyMap(), contentRestRequest("{}", emptyMap()).contentParser().map()); - e = expectThrows(ElasticsearchParseException.class, () -> + e = expectThrows(OpenSearchParseException.class, () -> contentRestRequest("", emptyMap(), emptyMap()).contentParser()); assertEquals("request body is required", e.getMessage()); } @@ -123,7 +123,7 @@ public void testApplyContentParser() throws IOException { } public void testContentOrSourceParam() throws IOException { - Exception e = expectThrows(ElasticsearchParseException.class, () -> + Exception e = expectThrows(OpenSearchParseException.class, () -> contentRestRequest("", emptyMap()).contentOrSourceParam()); assertEquals("request body or source parameter is required", e.getMessage()); assertEquals(new BytesArray("stuff"), contentRestRequest("stuff", emptyMap()).contentOrSourceParam().v2()); @@ -148,7 +148,7 @@ public void testHasContentOrSourceParam() throws IOException { } public void testContentOrSourceParamParser() throws IOException { - Exception e = expectThrows(ElasticsearchParseException.class, () -> + Exception e = expectThrows(OpenSearchParseException.class, () -> contentRestRequest("", emptyMap()).contentOrSourceParamParser()); assertEquals("request body or source parameter is required", e.getMessage()); assertEquals(emptyMap(), contentRestRequest("{}", emptyMap()).contentOrSourceParamParser().map()); @@ -218,14 +218,14 @@ public void testMultipleContentTypeHeaders() { } public void testRequiredContent() { - Exception e = expectThrows(ElasticsearchParseException.class, () -> + Exception e = expectThrows(OpenSearchParseException.class, () -> contentRestRequest("", emptyMap()).requiredContent()); assertEquals("request body is required", e.getMessage()); assertEquals(new BytesArray("stuff"), contentRestRequest("stuff", emptyMap()).requiredContent()); assertEquals(new BytesArray("stuff"), contentRestRequest("stuff", MapBuilder.newMapBuilder() .put("source", "stuff2").put("source_content_type", "application/json").immutableMap()).requiredContent()); - e = expectThrows(ElasticsearchParseException.class, () -> + e = expectThrows(OpenSearchParseException.class, () -> contentRestRequest("", MapBuilder.newMapBuilder() .put("source", "{\"foo\": \"stuff\"}").put("source_content_type", "application/json").immutableMap()) .requiredContent()); diff --git a/server/src/test/java/org/elasticsearch/script/ScriptTests.java b/server/src/test/java/org/elasticsearch/script/ScriptTests.java index ce9d0082e9f50..0d60caa8b6072 100644 --- a/server/src/test/java/org/elasticsearch/script/ScriptTests.java +++ b/server/src/test/java/org/elasticsearch/script/ScriptTests.java @@ -19,7 +19,7 @@ package org.elasticsearch.script; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.common.Strings; import org.elasticsearch.common.io.stream.InputStreamStreamInput; import org.elasticsearch.common.io.stream.OutputStreamStreamOutput; @@ -173,8 +173,8 @@ public void testParseFromObjectWrongFormat() { assertEquals("Script value should be a String or a Map", exc.getMessage()); } { - ElasticsearchParseException exc = expectThrows( - ElasticsearchParseException.class, + OpenSearchParseException exc = expectThrows( + OpenSearchParseException.class, () -> Script.parse(Collections.emptyMap()) ); assertEquals("Expected one of [source] or [id] fields, but found none", exc.getMessage()); @@ -185,8 +185,8 @@ public void testParseFromObjectWrongOptionsFormat() { Map map = new HashMap<>(); map.put("source", "doc['my_field']"); map.put("options", 3); - ElasticsearchParseException exc = expectThrows( - ElasticsearchParseException.class, + OpenSearchParseException exc = expectThrows( + OpenSearchParseException.class, () -> Script.parse(map) ); assertEquals("Value must be of type Map: [options]", exc.getMessage()); @@ -196,8 +196,8 @@ public void testParseFromObjectWrongParamsFormat() { Map map = new HashMap<>(); map.put("source", "doc['my_field']"); map.put("params", 3); - ElasticsearchParseException exc = expectThrows( - ElasticsearchParseException.class, + OpenSearchParseException exc = expectThrows( + OpenSearchParseException.class, () -> Script.parse(map) ); assertEquals("Value must be of type Map: [params]", exc.getMessage()); diff --git a/server/src/test/java/org/elasticsearch/search/aggregations/bucket/composite/CompositeAggregatorTests.java b/server/src/test/java/org/elasticsearch/search/aggregations/bucket/composite/CompositeAggregatorTests.java index 7e9fa181da473..d1f4dc36db5a1 100644 --- a/server/src/test/java/org/elasticsearch/search/aggregations/bucket/composite/CompositeAggregatorTests.java +++ b/server/src/test/java/org/elasticsearch/search/aggregations/bucket/composite/CompositeAggregatorTests.java @@ -48,7 +48,7 @@ import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.NumericUtils; import org.apache.lucene.util.TestUtil; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.common.geo.GeoPoint; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.text.Text; @@ -1474,7 +1474,7 @@ public void testWithDateHistogramAndFormat() throws IOException { } public void testThatDateHistogramFailsFormatAfter() throws IOException { - ElasticsearchParseException exc = expectThrows(ElasticsearchParseException.class, + OpenSearchParseException exc = expectThrows(OpenSearchParseException.class, () -> testSearchCase(Arrays.asList(new MatchAllDocsQuery(), new DocValuesFieldExistsQuery("date")), Collections.emptyList(), () -> { DateHistogramValuesSourceBuilder histo = new DateHistogramValuesSourceBuilder("date") @@ -1490,7 +1490,7 @@ public void testThatDateHistogramFailsFormatAfter() throws IOException { assertThat(exc.getCause(), instanceOf(IllegalArgumentException.class)); assertThat(exc.getCause().getMessage(), containsString("now() is not supported in [after] key")); - exc = expectThrows(ElasticsearchParseException.class, + exc = expectThrows(OpenSearchParseException.class, () -> testSearchCase(Arrays.asList(new MatchAllDocsQuery(), new DocValuesFieldExistsQuery("date")), Collections.emptyList(), () -> { DateHistogramValuesSourceBuilder histo = new DateHistogramValuesSourceBuilder("date") diff --git a/server/src/test/java/org/elasticsearch/search/aggregations/bucket/range/DateRangeAggregatorTests.java b/server/src/test/java/org/elasticsearch/search/aggregations/bucket/range/DateRangeAggregatorTests.java index 3c14aa75af93a..8db2d2891b7e5 100644 --- a/server/src/test/java/org/elasticsearch/search/aggregations/bucket/range/DateRangeAggregatorTests.java +++ b/server/src/test/java/org/elasticsearch/search/aggregations/bucket/range/DateRangeAggregatorTests.java @@ -30,7 +30,7 @@ import org.apache.lucene.search.Query; import org.apache.lucene.store.Directory; import org.apache.lucene.util.BytesRef; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.common.CheckedConsumer; import org.elasticsearch.index.mapper.DateFieldMapper; import org.elasticsearch.index.mapper.KeywordFieldMapper; @@ -252,7 +252,7 @@ public void testUnmappedWithBadMissingField() { MappedFieldType fieldType = new NumberFieldMapper.NumberFieldType(NUMBER_FIELD_NAME, NumberFieldMapper.NumberType.INTEGER); - expectThrows(ElasticsearchParseException.class, + expectThrows(OpenSearchParseException.class, () -> testCase(aggregationBuilder, new MatchAllDocsQuery(), iw -> { iw.addDocument(singleton(new NumericDocValuesField(NUMBER_FIELD_NAME, 7))); iw.addDocument(singleton(new NumericDocValuesField(NUMBER_FIELD_NAME, 1))); diff --git a/server/src/test/java/org/elasticsearch/search/rescore/QueryRescorerBuilderTests.java b/server/src/test/java/org/elasticsearch/search/rescore/QueryRescorerBuilderTests.java index 93d856145583f..6faca84823e19 100644 --- a/server/src/test/java/org/elasticsearch/search/rescore/QueryRescorerBuilderTests.java +++ b/server/src/test/java/org/elasticsearch/search/rescore/QueryRescorerBuilderTests.java @@ -20,7 +20,7 @@ package org.elasticsearch.search.rescore; import org.apache.lucene.search.Query; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.Version; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.common.ParsingException; @@ -136,7 +136,7 @@ public void testFromXContent() throws IOException { * test that build() outputs a {@link RescoreContext} that has the same properties * than the test builder */ - public void testBuildRescoreSearchContext() throws ElasticsearchParseException, IOException { + public void testBuildRescoreSearchContext() throws OpenSearchParseException, IOException { final long nowInMillis = randomNonNegativeLong(); Settings indexSettings = Settings.builder() .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT).build(); diff --git a/server/src/test/java/org/elasticsearch/search/sort/GeoDistanceSortBuilderTests.java b/server/src/test/java/org/elasticsearch/search/sort/GeoDistanceSortBuilderTests.java index 02a788b50d6a9..cacf604ca6304 100644 --- a/server/src/test/java/org/elasticsearch/search/sort/GeoDistanceSortBuilderTests.java +++ b/server/src/test/java/org/elasticsearch/search/sort/GeoDistanceSortBuilderTests.java @@ -25,7 +25,7 @@ import org.apache.lucene.search.MatchAllDocsQuery; import org.apache.lucene.search.SortField; import org.apache.lucene.search.TermQuery; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.common.geo.GeoDistance; import org.elasticsearch.common.geo.GeoPoint; import org.elasticsearch.common.unit.DistanceUnit; @@ -567,13 +567,13 @@ public void testBuildInvalidPoints() throws IOException { { GeoDistanceSortBuilder sortBuilder = new GeoDistanceSortBuilder("fieldName", -180.0, 0.0); sortBuilder.validation(GeoValidationMethod.STRICT); - ElasticsearchParseException ex = expectThrows(ElasticsearchParseException.class, () -> sortBuilder.build(shardContextMock)); + OpenSearchParseException ex = expectThrows(OpenSearchParseException.class, () -> sortBuilder.build(shardContextMock)); assertEquals("illegal latitude value [-180.0] for [GeoDistanceSort] for field [fieldName].", ex.getMessage()); } { GeoDistanceSortBuilder sortBuilder = new GeoDistanceSortBuilder("fieldName", 0.0, -360.0); sortBuilder.validation(GeoValidationMethod.STRICT); - ElasticsearchParseException ex = expectThrows(ElasticsearchParseException.class, () -> sortBuilder.build(shardContextMock)); + OpenSearchParseException ex = expectThrows(OpenSearchParseException.class, () -> sortBuilder.build(shardContextMock)); assertEquals("illegal longitude value [-360.0] for [GeoDistanceSort] for field [fieldName].", ex.getMessage()); } } diff --git a/server/src/test/java/org/elasticsearch/search/suggest/completion/GeoContextMappingTests.java b/server/src/test/java/org/elasticsearch/search/suggest/completion/GeoContextMappingTests.java index 37d5ba6bc4153..36877fd995db9 100644 --- a/server/src/test/java/org/elasticsearch/search/suggest/completion/GeoContextMappingTests.java +++ b/server/src/test/java/org/elasticsearch/search/suggest/completion/GeoContextMappingTests.java @@ -20,7 +20,7 @@ package org.elasticsearch.search.suggest.completion; import org.apache.lucene.index.IndexableField; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentBuilder; @@ -230,7 +230,7 @@ public void testMalformedGeoField() throws Exception { mapping.endObject(); mapping.endObject(); - ElasticsearchParseException ex = expectThrows(ElasticsearchParseException.class, + OpenSearchParseException ex = expectThrows(OpenSearchParseException.class, () -> createIndex("test", Settings.EMPTY, "type1", mapping)); assertThat(ex.getMessage(), equalTo("field [pin] referenced in context [st] must be mapped to geo_point, found [" + type + "]")); @@ -260,7 +260,7 @@ public void testMissingGeoField() throws Exception { mapping.endObject(); mapping.endObject(); - ElasticsearchParseException ex = expectThrows(ElasticsearchParseException.class, + OpenSearchParseException ex = expectThrows(OpenSearchParseException.class, () -> createIndex("test", Settings.EMPTY, "type1", mapping)); assertThat(ex.getMessage(), equalTo("field [pin] referenced in context [st] is not defined in the mapping")); diff --git a/server/src/test/java/org/elasticsearch/snapshots/BlobStoreFormatTests.java b/server/src/test/java/org/elasticsearch/snapshots/BlobStoreFormatTests.java index 8abb15407e79f..aa116408445a2 100644 --- a/server/src/test/java/org/elasticsearch/snapshots/BlobStoreFormatTests.java +++ b/server/src/test/java/org/elasticsearch/snapshots/BlobStoreFormatTests.java @@ -20,7 +20,7 @@ package org.elasticsearch.snapshots; import org.elasticsearch.OpenSearchCorruptionException; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.common.blobstore.BlobContainer; import org.elasticsearch.common.blobstore.BlobMetadata; import org.elasticsearch.common.blobstore.BlobPath; @@ -70,7 +70,7 @@ public static BlobObj fromXContent(XContentParser parser) throws IOException { if (token == XContentParser.Token.START_OBJECT) { while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) { if (token != XContentParser.Token.FIELD_NAME) { - throw new ElasticsearchParseException("unexpected token [{}]", token); + throw new OpenSearchParseException("unexpected token [{}]", token); } String currentFieldName = parser.currentName(); token = parser.nextToken(); @@ -78,15 +78,15 @@ public static BlobObj fromXContent(XContentParser parser) throws IOException { if ("text" .equals(currentFieldName)) { text = parser.text(); } else { - throw new ElasticsearchParseException("unexpected field [{}]", currentFieldName); + throw new OpenSearchParseException("unexpected field [{}]", currentFieldName); } } else { - throw new ElasticsearchParseException("unexpected token [{}]", token); + throw new OpenSearchParseException("unexpected token [{}]", token); } } } if (text == null) { - throw new ElasticsearchParseException("missing mandatory parameter text"); + throw new OpenSearchParseException("missing mandatory parameter text"); } return new BlobObj(text); } diff --git a/test/framework/src/main/java/org/elasticsearch/test/AbstractQueryTestCase.java b/test/framework/src/main/java/org/elasticsearch/test/AbstractQueryTestCase.java index 1fbec4f2a8f6e..b411ebdd44b9f 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/AbstractQueryTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/test/AbstractQueryTestCase.java @@ -26,7 +26,7 @@ import org.apache.lucene.search.Query; import org.apache.lucene.search.TermQuery; import org.apache.lucene.search.spans.SpanBoostQuery; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.Version; import org.elasticsearch.action.support.PlainActionFuture; import org.elasticsearch.common.ParsingException; @@ -180,7 +180,7 @@ public void testUnknownObjectException() throws IOException { if (expectedException) { fail("some parsing exception expected for query: " + testQuery); } - } catch (ParsingException | ElasticsearchParseException | XContentParseException e) { + } catch (ParsingException | OpenSearchParseException | XContentParseException e) { // different kinds of exception wordings depending on location // of mutation, so no simple asserts possible here if (expectedException == false) { diff --git a/test/framework/src/main/java/org/elasticsearch/test/TestCustomMetadata.java b/test/framework/src/main/java/org/elasticsearch/test/TestCustomMetadata.java index e57e3f5e3ad75..4de5ba75d7688 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/TestCustomMetadata.java +++ b/test/framework/src/main/java/org/elasticsearch/test/TestCustomMetadata.java @@ -19,7 +19,7 @@ package org.elasticsearch.test; -import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.OpenSearchParseException; import org.elasticsearch.cluster.AbstractNamedDiffable; import org.elasticsearch.cluster.NamedDiff; import org.elasticsearch.cluster.metadata.Metadata; @@ -82,18 +82,18 @@ public static T fromXContent(Function