Skip to content

Commit af5dc76

Browse files
authored
Fix #1274: add volatile for SerializedString fields (#1297)
1 parent 222ac2a commit af5dc76

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

release-notes/CREDITS-2.x

+5-1
Original file line numberDiff line numberDiff line change
@@ -433,4 +433,8 @@ Antonin Janec (@xtonic)
433433
* Contributed #1217: Optimize char comparison using bitwise OR
434434
(2.17.0)
435435
* Contributed #1218: Simplify Unicode surrogate pair conversion for generation
436-
(2.17.0)
436+
(2.17.0)
437+
438+
Jared Stehler (@jaredstehler)
439+
* Reported, contributed fix for #1274: `NUL`-corrupted keys, values on JSON serialization
440+
(2.18.0)

release-notes/VERSION-2.x

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ a pure JSON library.
3030
to prevent use by downstream consumers
3131
(requested by @seadbrane)
3232
#1271: Deprecate `LockFreePool` implementation in 2.18 (remove from 3.0)
33+
#1274: `NUL`-corrupted keys, values on JSON serialization
34+
(reported, fix contributed by Jared S)
3335
#1277: Add back Java 22 optimisation in FastDoubleParser
3436

3537
2.17.1 (04-May-2024)

src/main/java/com/fasterxml/jackson/core/io/SerializedString.java

+8-8
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,17 @@ public class SerializedString
3737
* search framework; and they believed this is an important optimization for
3838
* heaviest, multi-core deployed use cases.
3939
*/
40-
/*
41-
* 22-Sep-2013, tatu: FWIW, there have been no reports of problems in this
42-
* area, or anything pointing to it. So I think we are safe up to JDK7
43-
* and hopefully beyond.
44-
*/
40+
// 22-Sep-2013, tatu: FWIW, there have been no reports of problems in this
41+
// area, or anything pointing to it. So I think we are safe up to JDK7
42+
// and hopefully beyond.
43+
// 09-Jun-2024, tatu: Until we are not. As per [core#1274] there are reasons to
44+
// believe `volatile` is actually needed, so will be added in 2.18.0
4545

46-
protected /*volatile*/ byte[] _quotedUTF8Ref;
46+
protected volatile byte[] _quotedUTF8Ref;
4747

48-
protected /*volatile*/ byte[] _unquotedUTF8Ref;
48+
protected volatile byte[] _unquotedUTF8Ref;
4949

50-
protected /*volatile*/ char[] _quotedChars;
50+
protected volatile char[] _quotedChars;
5151

5252
public SerializedString(String v) {
5353
_value = Objects.requireNonNull(v, "Null String illegal for SerializedString");

0 commit comments

Comments
 (0)