From d90a440bf7f216ee01de3ef554d601ec66f11c66 Mon Sep 17 00:00:00 2001 From: Lee Hinman Date: Thu, 15 Feb 2018 11:01:01 -0700 Subject: [PATCH] Add XContentHelper shim for move to passing in deprecation handler (#28684) In order to allow us to gradually move to passing the deprecation handler is, we need a shim that contains both the non-passed and passed version. Relates to #28504 --- .../common/xcontent/XContentHelper.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) 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 e5451e1b7ce..eb32f9cd853 100644 --- a/server/src/main/java/org/elasticsearch/common/xcontent/XContentHelper.java +++ b/server/src/main/java/org/elasticsearch/common/xcontent/XContentHelper.java @@ -40,10 +40,20 @@ public class XContentHelper { /** * Creates a parser based on the bytes provided - * @deprecated use {@link #createParser(NamedXContentRegistry, DeprecationHandler, BytesReference, XContentType)} to avoid content type auto-detection + * @deprecated this is a temporary shim and will be removed shortly */ @Deprecated public static XContentParser createParser(NamedXContentRegistry xContentRegistry, BytesReference bytes) throws IOException { + return createParser(xContentRegistry, LoggingDeprecationHandler.INSTANCE, bytes); + } + + /** + * Creates a parser based on the bytes provided + * @deprecated use {@link #createParser(NamedXContentRegistry, DeprecationHandler, BytesReference, XContentType)} to avoid content type auto-detection + */ + @Deprecated + public static XContentParser createParser(NamedXContentRegistry xContentRegistry, DeprecationHandler deprecationHandler, + BytesReference bytes) throws IOException { Compressor compressor = CompressorFactory.compressor(bytes); if (compressor != null) { InputStream compressedInput = compressor.streamInput(bytes.streamInput()); @@ -51,7 +61,7 @@ public class XContentHelper { compressedInput = new BufferedInputStream(compressedInput); } final XContentType contentType = XContentFactory.xContentType(compressedInput); - return XContentFactory.xContent(contentType).createParser(xContentRegistry, LoggingDeprecationHandler.INSTANCE, compressedInput); + return XContentFactory.xContent(contentType).createParser(xContentRegistry, deprecationHandler, compressedInput); } else { return XContentFactory.xContent(bytes).createParser(xContentRegistry, bytes.streamInput()); }