Package com.amazonaws.xray.internal
Class RecyclableBuffers
- java.lang.Object
-
- com.amazonaws.xray.internal.RecyclableBuffers
-
public final class RecyclableBuffers extends java.lang.Object
ThreadLocal
buffers for use when creating new derived objects such asString
s. These buffers are reused within a single thread - it is _not safe_ to use the buffer to generate multiple derived objects at the same time because the same memory will be used. In general, you should get a temporary buffer, fill it with data, and finish by converting into the derived object within the same method to avoid multiple usages of the same buffer.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static byte[]
bytes(int length)
AThreadLocal
byte[]
of lengthlength
.static char[]
chars(int length)
AThreadLocal
char[]
of lengthlength
.static java.lang.StringBuilder
stringBuilder()
AThreadLocal
StringBuilder
.
-
-
-
Method Detail
-
stringBuilder
public static java.lang.StringBuilder stringBuilder()
AThreadLocal
StringBuilder
. Take care when filling a large value into this buffer because the memory will remain for the lifetime of the thread.
-
chars
public static char[] chars(int length)
AThreadLocal
char[]
of lengthlength
. The array is not zeroed in any way - every character of a resultingString
must be set explicitly. The array returned may be longer thanlength
- always explicitly set the length when using the result, for example by callingString.valueOf(char[], int, int)
.
-
bytes
public static byte[] bytes(int length)
AThreadLocal
byte[]
of lengthlength
. The array is not zeroed in any way.
-
-