Skip to content

Commit 3e0a7c2

Browse files
committed
Add comments
1 parent b23c658 commit 3e0a7c2

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,17 @@ private void packStringWithGetBytes(String s)
448448
private void prepareEncoder()
449449
{
450450
if (encoder == null) {
451+
/**
452+
* Even if String object contains invalid UTF-8 characters, we should not throw any exception.
453+
*
454+
* The following exception has happened before:
455+
*
456+
* org.msgpack.core.MessageStringCodingException: java.nio.charset.MalformedInputException: Input length = 1
457+
* at org.msgpack.core.MessagePacker.encodeStringToBufferAt(MessagePacker.java:467) ~[msgpack-core-0.8.6.jar:na]
458+
* at org.msgpack.core.MessagePacker.packString(MessagePacker.java:535) ~[msgpack-core-0.8.6.jar:na]
459+
*
460+
* This happened on JVM 7. But no ideas how to reproduce.
461+
*/
451462
this.encoder = MessagePack.UTF8.newEncoder()
452463
.onMalformedInput(CodingErrorAction.REPLACE)
453464
.onUnmappableCharacter(CodingErrorAction.REPLACE);

0 commit comments

Comments
 (0)