Top Description Fields Constructors Methods
com.fasterxml.jackson.core.util

public Class BufferRecyclers

extends Object
Class Inheritance
Annotations
@Deprecated
Imports
java.lang.ref.SoftReference, com.fasterxml.jackson.core.io.JsonStringEncoder

Deprecated

Since 2.16 recycling aspects are handled via RecyclerPool.

Helper entity used to control access to simple buffer recycling scheme used for some encoding, decoding tasks.
Since
2.9.2
See Also
BufferRecycler

Field Summary

Modifier and TypeField and Description
private static final ThreadLocalBufferManager
_bufferRecyclerTracker

Flag that indicates whether BufferRecycler instances should be tracked.

protected static final ThreadLocal<SoftReference<BufferRecycler>>
_recyclerRef

This ThreadLocal contains a java.lang.ref.SoftReference to a BufferRecycler used to provide a low-cost buffer recycling between reader and writer instances.

public static final String
SYSTEM_PROPERTY_TRACK_REUSABLE_BUFFERS

System property that is checked to see if recycled buffers (see BufferRecycler) should be tracked, for purpose of forcing release of all such buffers, typically during major garbage-collection.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static byte[]

Returns:

String encoded as UTF-8 bytes.
encodeAsUTF8
(String
String to encode
text
)

Deprecated Since 2.10 call JsonStringEncoder#getInstance() and then encodeAsUTF8()) instead.
Not to be used any more.
public static BufferRecycler

Returns:

BufferRecycler to use
getBufferRecycler
()

Deprecated Since 2.16 should use RecyclerPool abstraction instead of calling static methods of this class
Main accessor to call for accessing possibly recycled BufferRecycler instance.
public static JsonStringEncoder

Returns:

JsonStringEncoder instance to use.
getJsonStringEncoder
()

Deprecated Since 2.10 call JsonStringEncoder#getInstance() instead.
Not to be used any more.
public static char[]

Returns:

Quoted text as char[]
quoteAsJsonText
(String
String to quote
rawText
)

Deprecated Since 2.10 call JsonStringEncoder#getInstance() and then quoteAsString()) instead.
Not to be used any more:
public static void
quoteAsJsonText(CharSequence
Textual content to quote
input
,
StringBuilder
Builder to append quoted content
output
)

Deprecated Since 2.10 call JsonStringEncoder#getInstance() and then quoteAsString()) instead.
Not to be used any more.
public static byte[]

Returns:

Quoted text as byte[]
quoteAsJsonUTF8
(String
String to quote
rawText
)

Deprecated Since 2.10 call JsonStringEncoder#getInstance() (and then quoteAsUTF8()) instead.
Not to be used any more.
public static int

Returns:

Number of buffers released, if tracking enabled (zero or more); -1 if tracking not enabled.
releaseBuffers
()

Specialized method that will release all recycled BufferRecycler if (and only if) recycler tracking has been enabled (see SYSTEM_PROPERTY_TRACK_REUSABLE_BUFFERS).

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_bufferRecyclerTrackerback to summary
private static final ThreadLocalBufferManager _bufferRecyclerTracker

Flag that indicates whether BufferRecycler instances should be tracked.

_recyclerRefback to summary
protected static final ThreadLocal<SoftReference<BufferRecycler>> _recyclerRef

This ThreadLocal contains a java.lang.ref.SoftReference to a BufferRecycler used to provide a low-cost buffer recycling between reader and writer instances.

SYSTEM_PROPERTY_TRACK_REUSABLE_BUFFERSback to summary
public static final String SYSTEM_PROPERTY_TRACK_REUSABLE_BUFFERS

System property that is checked to see if recycled buffers (see BufferRecycler) should be tracked, for purpose of forcing release of all such buffers, typically during major garbage-collection.

Since
2.9.6

Constructor Detail

BufferRecyclersback to summary
public BufferRecyclers()

Method Detail

encodeAsUTF8back to summary
public static byte[] encodeAsUTF8(String text)

Deprecated

Since 2.10 call JsonStringEncoder#getInstance() and then encodeAsUTF8()) instead. NOTE: was accidentally removed but reintroduced as deprecated in 2.12.5, to be removed from 3.0)

Not to be used any more.

Parameters
text:String

String to encode

Returns:byte[]

String encoded as UTF-8 bytes.

Annotations
@Deprecated
getBufferRecyclerback to summary
public static BufferRecycler getBufferRecycler()

Deprecated

Since 2.16 should use RecyclerPool abstraction instead of calling static methods of this class

Main accessor to call for accessing possibly recycled BufferRecycler instance.

Returns:BufferRecycler

BufferRecycler to use

Annotations
@Deprecated
getJsonStringEncoderback to summary
public static JsonStringEncoder getJsonStringEncoder()

Deprecated

Since 2.10 call JsonStringEncoder#getInstance() instead. NOTE: was accidentally removed but reintroduced as deprecated in 2.12.5, to be removed from 3.0)

Not to be used any more.

Returns:JsonStringEncoder

JsonStringEncoder instance to use.

Annotations
@Deprecated
quoteAsJsonTextback to summary
public static char[] quoteAsJsonText(String rawText)

Deprecated

Since 2.10 call JsonStringEncoder#getInstance() and then quoteAsString()) instead. NOTE: was accidentally removed but reintroduced as deprecated in 2.12.5, to be removed from 3.0)

Not to be used any more:

Parameters
rawText:String

String to quote

Returns:char[]

Quoted text as char[]

Annotations
@Deprecated
quoteAsJsonTextback to summary
public static void quoteAsJsonText(CharSequence input, StringBuilder output)

Deprecated

Since 2.10 call JsonStringEncoder#getInstance() and then quoteAsString()) instead. NOTE: was accidentally removed but reintroduced as deprecated in 2.12.5, to be removed from 3.0)

Not to be used any more.

Parameters
input:CharSequence

Textual content to quote

output:StringBuilder

Builder to append quoted content

Annotations
@Deprecated
quoteAsJsonUTF8back to summary
public static byte[] quoteAsJsonUTF8(String rawText)

Deprecated

Since 2.10 call JsonStringEncoder#getInstance() (and then quoteAsUTF8()) instead. NOTE: was accidentally removed but reintroduced as deprecated in 2.12.5, to be removed from 3.0)

Not to be used any more.

Parameters
rawText:String

String to quote

Returns:byte[]

Quoted text as byte[]

Annotations
@Deprecated
releaseBuffersback to summary
public static int releaseBuffers()

Specialized method that will release all recycled BufferRecycler if (and only if) recycler tracking has been enabled (see SYSTEM_PROPERTY_TRACK_REUSABLE_BUFFERS). This method is usually called on shutdown of the container like Application Server to ensure that no references are reachable via ThreadLocals as this may cause unintentional retention of sizable amounts of memory. It may also be called regularly if GC for some reason does not clear up SoftReferences aggressively enough.

Returns:int

Number of buffers released, if tracking enabled (zero or more); -1 if tracking not enabled.

Since
2.9.6