Seemingly impossible JSON serialization -- NUL
-corrupted keys, values. Worse on JDK21?
#215
Unanswered
jaredstehler
asked this question in
Q&A
Replies: 2 comments 4 replies
-
Very interesting (and bit alarming). I do not remember hearing about this issue before; your guess wrt |
Beta Was this translation helpful? Give feedback.
0 replies
-
Just want to throw in we also sometimes see this issue for half a year or so now; just some random characters in the payload get replaced with |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm posting this as a long-shot attempt to see if anyone recognizes this issue or what might be causing it; this is definitely a confusing one!
tl;dr -- we have observed messages in our kafka topics which have strings where some portion of them have been written as unicode
NUL
bytes. we are using jackson to serialize objects into json asbyte[]
. this occurs for keys as well as values, which means it's not user input. it's also quite intermittent, though it seems to occur much more frequently on Java 21 than on Java 17.We noticed this issue a few months back in perhaps one or two messages, and it went away. However, when we started running our producer apps on Java 21, this became a more widespread issue, though still highly intermittent (i.e. ~5 out of millions of messages would exhibit this behavior).
The issue manifests as JSON with corrupted keys or values; a corrupted string has the correct length, but with up to 100% if its suffix chars replaced by
NUL
(0
) bytes. Since every case I've observed shows the corruption confined to within "valid" json structure, it would appear that this is occuring in the jackson layer, and not somewhere beyond.Looking at
SerializedString
, there is an old comment aboutvolatile
fields; I have yet to reproduce this in a way to capture that level of the serializer state to (dis)prove relevance here: https://github.com/FasterXML/jackson-core/blob/93e18c6e2fc06ebd0bb9a74c4db462662f09db20/src/main/java/com/fasterxml/jackson/core/io/SerializedString.java#L26-L43The messages occur after an app has been running for ~ 1 to 2 hours, but again, quite rare and intermittent.
This is with jackson
2.12.6
, and we are not using afterburner or blackbird. Producers are uniformly running onarm64
hosts, withG1GC
.Here are some representative examples of the issue.. the invalid keys are all bean properties, there are no generic maps being serialized here.
(note that the actual binary data has
NUL
bytes, not encoded\u0000
text, which we see on the deser side as)should be
newState.amendmentDetails
:should be
oldPropertyDefinition.propertyRequirements
:should be
newPropertyDefinition.property
:in this case, the value is a java
enum
, should be"OR"
:Beta Was this translation helpful? Give feedback.
All reactions