File tree Expand file tree Collapse file tree
src/main/java/org/msgpack/type Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2929
3030class ByteArrayRawValueImpl extends AbstractRawValue {
3131 private static ByteArrayRawValueImpl emptyInstance = new ByteArrayRawValueImpl (new byte [0 ], true );
32-
32+
3333 public static RawValue getEmptyInstance () {
3434 return emptyInstance ;
3535 }
36+
37+ private static final ThreadLocal <CharsetDecoder > decoderStore = new ThreadLocal <CharsetDecoder >() {
38+ @ Override
39+ protected CharsetDecoder initialValue () {
40+ return Charset .forName ("UTF-8" ).newDecoder ()
41+ .onMalformedInput (CodingErrorAction .REPORT )
42+ .onUnmappableCharacter (CodingErrorAction .REPORT );
43+ }
44+ };
3645
3746 private byte [] bytes ;
3847
@@ -58,9 +67,7 @@ public byte[] getByteArray() {
5867
5968 @ Override
6069 public String getString () {
61- CharsetDecoder decoder = Charset .forName ("UTF-8" ).newDecoder ()
62- .onMalformedInput (CodingErrorAction .REPORT )
63- .onUnmappableCharacter (CodingErrorAction .REPORT );
70+ CharsetDecoder decoder = decoderStore .get ();
6471 try {
6572 return decoder .decode (ByteBuffer .wrap (bytes )).toString ();
6673 } catch (CharacterCodingException ex ) {
You can’t perform that action at this time.
0 commit comments