From 0dcfde069a2c9076143c4b90801cd7d5074e8338 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Thu, 26 Aug 2021 15:47:27 -0700 Subject: [PATCH] Fix #713: add back `BufferRecyclers.getJsonStringEncoder()` (removed in 2.10.0) --- release-notes/VERSION-2.x | 4 +- .../jackson/core/util/BufferRecyclers.java | 68 +++++++++++++++++++ 2 files changed, 71 insertions(+), 1 deletion(-) diff --git a/release-notes/VERSION-2.x b/release-notes/VERSION-2.x index 6e7439107f..bf20e2b8da 100644 --- a/release-notes/VERSION-2.x +++ b/release-notes/VERSION-2.x @@ -16,7 +16,9 @@ JSON library. (not yet released) -#712: (partial) Optimize array allocation by JsonStringEncoder +#712: (partial) Optimize array allocation by `JsonStringEncoder` +#713: Add back accidentally removed `JsonStringEncoder` related methods in + `BufferRecyclers` (like `getJsonStringEncoder()`) 2.11.4 (12-Dec-2020) diff --git a/src/main/java/com/fasterxml/jackson/core/util/BufferRecyclers.java b/src/main/java/com/fasterxml/jackson/core/util/BufferRecyclers.java index 4936ffaeb3..14703f35ea 100644 --- a/src/main/java/com/fasterxml/jackson/core/util/BufferRecyclers.java +++ b/src/main/java/com/fasterxml/jackson/core/util/BufferRecyclers.java @@ -2,6 +2,8 @@ import java.lang.ref.SoftReference; +import com.fasterxml.jackson.core.io.JsonStringEncoder; + /** * Helper entity used to control access to simple buffer recyling scheme used for * some encoding, decoding tasks. @@ -94,4 +96,70 @@ public static int releaseBuffers() { } return -1; } + + /* + /********************************************************************** + /* Obsolete things re-introduced in 2.12.5 after accidental direct + /* removal from 2.10.0 + /********************************************************************** + */ + + /** + * Not to be used any more: call {@link JsonStringEncoder#getInstance()} instead. + * + * @deprecated Since 2.10 (note: was accidentally removed but reintroduced as deprecated + * in 2.12.5, to be removed from 3.0) + */ + @Deprecated + public static JsonStringEncoder getJsonStringEncoder() { + return JsonStringEncoder.getInstance(); + } + + /** + * Not to be used any more: call {@link JsonStringEncoder#getInstance()} (and then + * {@code encodeAsUTF8()}) instead. + * + * @deprecated Since 2.10 (note: was accidentally removed but reintroduced as deprecated + * in 2.12.5, to be removed from 3.0) + */ + @Deprecated + public static byte[] encodeAsUTF8(String text) { + return JsonStringEncoder.getInstance().encodeAsUTF8(text); + } + + /** + * Not to be used any more: call {@link JsonStringEncoder#getInstance()} (and then + * {@code quoteAsString()}) instead. + * + * @deprecated Since 2.10 (note: was accidentally removed but reintroduced as deprecated + * in 2.12.5, to be removed from 3.0) + */ + @Deprecated + public static char[] quoteAsJsonText(String rawText) { + return JsonStringEncoder.getInstance().quoteAsString(rawText); + } + + /** + * Not to be used any more: call {@link JsonStringEncoder#getInstance()} (and then + * {@code quoteAsString()}) instead. + * + * @deprecated Since 2.10 (note: was accidentally removed but reintroduced as deprecated + * in 2.12.5, to be removed from 3.0) + */ + @Deprecated + public static void quoteAsJsonText(CharSequence input, StringBuilder output) { + JsonStringEncoder.getInstance().quoteAsString(input, output); + } + + /** + * Not to be used any more: call {@link JsonStringEncoder#getInstance()} (and then + * {@code quoteAsUTF8()}) instead. + * + * @deprecated Since 2.10 (note: was accidentally removed but reintroduced as deprecated + * in 2.12.5, to be removed from 3.0) + */ + @Deprecated + public static byte[] quoteAsJsonUTF8(String rawText) { + return JsonStringEncoder.getInstance().quoteAsUTF8(rawText); + } }