Skip to content

Commit

Permalink
Fix #713: add back BufferRecyclers.getJsonStringEncoder() (removed …
Browse files Browse the repository at this point in the history
…in 2.10.0)
  • Loading branch information
cowtowncoder committed Aug 26, 2021
1 parent abc7f13 commit 0dcfde0
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 1 deletion.
4 changes: 3 additions & 1 deletion release-notes/VERSION-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
68 changes: 68 additions & 0 deletions src/main/java/com/fasterxml/jackson/core/util/BufferRecyclers.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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);
}
}

0 comments on commit 0dcfde0

Please sign in to comment.