Skip to content

Commit 1607c93

Browse files
authored
Remove createParser variant (#79954)
In #79814 I deprecated many variants of `XContent#createParser` in favor of some new variants that bundle many of the arguments. This removes one of the deprecated variants by converting all call sites to the new variant.
1 parent 4db5fc5 commit 1607c93

File tree

5 files changed

+10
-32
lines changed

5 files changed

+10
-32
lines changed

libs/x-content/src/main/java/org/elasticsearch/xcontent/XContent.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,4 @@ default XContentParser createParser(NamedXContentRegistry registry, DeprecationH
100100
* Creates a parser over the provided reader.
101101
*/
102102
XContentParser createParser(XContentParserConfiguration config, Reader reader) throws IOException;
103-
104-
/**
105-
* Creates a parser over the provided reader.
106-
* @deprecated Use {@link #createParser(XContentParserConfiguration, Reader)}
107-
*/
108-
@Deprecated
109-
default XContentParser createParser(NamedXContentRegistry registry, DeprecationHandler deprecationHandler, Reader reader)
110-
throws IOException {
111-
return createParser(XContentParserConfiguration.EMPTY.withRegistry(registry).withDeprecationHandler(deprecationHandler), reader);
112-
}
113103
}

test/framework/src/main/java/org/elasticsearch/common/logging/JsonLogsStream.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@
88

99
package org.elasticsearch.common.logging;
1010

11-
import org.elasticsearch.xcontent.DeprecationHandler;
12-
import org.elasticsearch.xcontent.NamedXContentRegistry;
1311
import org.elasticsearch.xcontent.ObjectParser;
1412
import org.elasticsearch.xcontent.XContentParser;
13+
import org.elasticsearch.xcontent.XContentParserConfiguration;
1514
import org.elasticsearch.xcontent.json.JsonXContent;
1615

1716
import java.io.BufferedReader;
@@ -38,11 +37,7 @@ public class JsonLogsStream {
3837

3938
private JsonLogsStream(BufferedReader reader, ObjectParser<JsonLogLine, Void> logLineParser) throws IOException {
4039
this.reader = reader;
41-
this.parser = JsonXContent.jsonXContent.createParser(
42-
NamedXContentRegistry.EMPTY,
43-
DeprecationHandler.THROW_UNSUPPORTED_OPERATION,
44-
reader
45-
);
40+
this.parser = JsonXContent.jsonXContent.createParser(XContentParserConfiguration.EMPTY, reader);
4641
this.logLineParser = logLineParser;
4742
}
4843

x-pack/plugin/security/cli/src/main/java/org/elasticsearch/xpack/security/cli/CertificateGenerateTool.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,14 @@
2727
import org.elasticsearch.common.network.InetAddresses;
2828
import org.elasticsearch.common.ssl.PemUtils;
2929
import org.elasticsearch.common.util.set.Sets;
30-
import org.elasticsearch.common.xcontent.LoggingDeprecationHandler;
3130
import org.elasticsearch.core.PathUtils;
3231
import org.elasticsearch.core.SuppressForbidden;
3332
import org.elasticsearch.env.Environment;
3433
import org.elasticsearch.xcontent.ConstructingObjectParser;
35-
import org.elasticsearch.xcontent.NamedXContentRegistry;
3634
import org.elasticsearch.xcontent.ObjectParser;
3735
import org.elasticsearch.xcontent.ParseField;
3836
import org.elasticsearch.xcontent.XContentParser;
37+
import org.elasticsearch.xcontent.XContentParserConfiguration;
3938
import org.elasticsearch.xcontent.XContentType;
4039
import org.elasticsearch.xpack.core.ssl.CertParsingUtils;
4140

@@ -327,10 +326,9 @@ static Collection<CertificateInformation> parseAndValidateFile(Terminal terminal
327326
*/
328327
static Collection<CertificateInformation> parseFile(Path file) throws Exception {
329328
try (Reader reader = Files.newBufferedReader(file)) {
330-
// EMPTY is safe here because we never use namedObject
331-
XContentParser xContentParser = XContentType.YAML.xContent()
332-
.createParser(NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, reader);
333-
return InputFileParser.PARSER.parse(xContentParser, new ArrayList<>(), null);
329+
try (XContentParser xContentParser = XContentType.YAML.xContent().createParser(XContentParserConfiguration.EMPTY, reader)) {
330+
return InputFileParser.PARSER.parse(xContentParser, new ArrayList<>(), null);
331+
}
334332
}
335333
}
336334

x-pack/plugin/security/cli/src/main/java/org/elasticsearch/xpack/security/cli/CertificateTool.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,16 @@
3131
import org.elasticsearch.common.network.InetAddresses;
3232
import org.elasticsearch.common.ssl.PemUtils;
3333
import org.elasticsearch.common.util.set.Sets;
34-
import org.elasticsearch.common.xcontent.LoggingDeprecationHandler;
3534
import org.elasticsearch.core.CheckedConsumer;
3635
import org.elasticsearch.core.CheckedFunction;
3736
import org.elasticsearch.core.PathUtils;
3837
import org.elasticsearch.core.SuppressForbidden;
3938
import org.elasticsearch.env.Environment;
4039
import org.elasticsearch.xcontent.ConstructingObjectParser;
41-
import org.elasticsearch.xcontent.NamedXContentRegistry;
4240
import org.elasticsearch.xcontent.ObjectParser;
4341
import org.elasticsearch.xcontent.ParseField;
4442
import org.elasticsearch.xcontent.XContentParser;
43+
import org.elasticsearch.xcontent.XContentParserConfiguration;
4544
import org.elasticsearch.xcontent.XContentType;
4645
import org.elasticsearch.xpack.core.ssl.CertParsingUtils;
4746

@@ -982,9 +981,7 @@ static Collection<CertificateInformation> parseAndValidateFile(Terminal terminal
982981
*/
983982
static Collection<CertificateInformation> parseFile(Path file) throws Exception {
984983
try (Reader reader = Files.newBufferedReader(file)) {
985-
// EMPTY is safe here because we never use namedObject
986-
XContentParser xContentParser = XContentType.YAML.xContent()
987-
.createParser(NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, reader);
984+
XContentParser xContentParser = XContentType.YAML.xContent().createParser(XContentParserConfiguration.EMPTY, reader);
988985
return CertificateToolParser.PARSER.parse(xContentParser, new ArrayList<>(), null);
989986
}
990987
}

x-pack/plugin/text-structure/src/main/java/org/elasticsearch/xpack/textstructure/structurefinder/NdJsonTextStructureFinderFactory.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66
*/
77
package org.elasticsearch.xpack.textstructure.structurefinder;
88

9-
import org.elasticsearch.xcontent.DeprecationHandler;
10-
import org.elasticsearch.xcontent.NamedXContentRegistry;
119
import org.elasticsearch.xcontent.XContentParser;
10+
import org.elasticsearch.xcontent.XContentParserConfiguration;
1211
import org.elasticsearch.xpack.core.textstructure.structurefinder.TextStructure;
1312

1413
import java.io.IOException;
@@ -40,8 +39,7 @@ public boolean canCreateFromSample(List<String> explanation, String sample, doub
4039
for (String sampleLine : sampleLines) {
4140
try (
4241
XContentParser parser = jsonXContent.createParser(
43-
NamedXContentRegistry.EMPTY,
44-
DeprecationHandler.THROW_UNSUPPORTED_OPERATION,
42+
XContentParserConfiguration.EMPTY,
4543
new ContextPrintingStringReader(sampleLine)
4644
)
4745
) {

0 commit comments

Comments
 (0)