Skip to content

Commit e65e7b7

Browse files
committed
Move encoder.reset() to prepareEncoder()
1 parent dfcf588 commit e65e7b7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

msgpack-core/src/main/java/org/msgpack/core/MessagePacker.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,7 @@ private void prepareEncoder()
449449
if (encoder == null) {
450450
this.encoder = MessagePack.UTF8.newEncoder();
451451
}
452+
encoder.reset();
452453
}
453454

454455
private int encodeStringToBufferAt(int pos, String s)
@@ -457,7 +458,6 @@ private int encodeStringToBufferAt(int pos, String s)
457458
ByteBuffer bb = buffer.sliceAsByteBuffer(pos, buffer.size() - pos);
458459
int startPosition = bb.position();
459460
CharBuffer in = CharBuffer.wrap(s);
460-
encoder.reset();
461461
CoderResult cr = encoder.encode(in, bb, true);
462462
if (cr.isError()) {
463463
try {
@@ -471,7 +471,7 @@ private int encodeStringToBufferAt(int pos, String s)
471471
// Underflow should be on to ensure all of the input string is encoded
472472
return -1;
473473
}
474-
// NOTE: This flush method does nothing if we use UTR8 encoder, but other general encoders require this
474+
// NOTE: This flush method does nothing if we use UTF8 encoder, but other general encoders require this
475475
cr = encoder.flush(bb);
476476
if (!cr.isUnderflow()) {
477477
return -1;

0 commit comments

Comments
 (0)