From e695c6ea21caa35de726a3821ecf4b47eb89f4d4 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Tue, 28 Jul 2026 20:57:52 -0700 Subject: [PATCH] Fix #742: use ArrayDeque, not Stack, for CBORParser --- .../java/tools/jackson/dataformat/cbor/CBORParser.java | 10 ++++++---- release-notes/CREDITS | 5 +++++ release-notes/VERSION | 3 +++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/cbor/src/main/java/tools/jackson/dataformat/cbor/CBORParser.java b/cbor/src/main/java/tools/jackson/dataformat/cbor/CBORParser.java index 2635cfc41..13dddb3cb 100644 --- a/cbor/src/main/java/tools/jackson/dataformat/cbor/CBORParser.java +++ b/cbor/src/main/java/tools/jackson/dataformat/cbor/CBORParser.java @@ -7,9 +7,9 @@ import java.math.BigInteger; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; +import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; -import java.util.Stack; import tools.jackson.core.*; import tools.jackson.core.base.ParserBase; @@ -206,7 +206,7 @@ public void push(boolean hasNamespace) { public void pop() { --_nestedDepth; - if (!_stringRefs.empty() && _stringRefs.peek().depth == _nestedDepth) { + if (!_stringRefs.isEmpty() && _stringRefs.peek().depth == _nestedDepth) { _stringRefs.pop(); } } @@ -216,10 +216,12 @@ public StringRefList peek() { } public boolean empty() { - return _stringRefs.empty(); + return _stringRefs.isEmpty(); } - private Stack _stringRefs = new Stack<>(); + // 28-Jul-2026, tatu: [dataformats-binary#742] Use non-synchronized + // `ArrayDeque` instead of (synchronized) `Stack` + private final ArrayDeque _stringRefs = new ArrayDeque<>(); private int _nestedDepth = 0; } diff --git a/release-notes/CREDITS b/release-notes/CREDITS index 2acaa1f0d..c2dbbec46 100644 --- a/release-notes/CREDITS +++ b/release-notes/CREDITS @@ -50,3 +50,8 @@ Juan Farré (@jafarre-bi) * Reported #700: (cbor, smile) `META-INF/services/tools.jackson.databind.ObjectMapper` references wrong class name (`...databind.CBORMapper` / `...databind.SmileMapper`) (3.1.5) + +Benoît Mériaux (@benoitmeriaux) + +* Reported #742: Use `ArrayDeque` instead of `Stack` in `CBORParser` + (3.1.6) diff --git a/release-notes/VERSION b/release-notes/VERSION index f3fa35465..b3bb22fc1 100644 --- a/release-notes/VERSION +++ b/release-notes/VERSION @@ -41,6 +41,9 @@ No changes since 3.1 actual length to `shouldReferenceString()` #736: (cbor) Long Object property names added to "stringref" reference table twice (NOTE: in 3.x this affected the `nextNameMatch()` decoding path as well) +#742: Use `ArrayDeque` instead of `Stack` in `CBORParser` + (reported by Benoît M) + (fix by @cowtowncoder, w/ Claude code) 3.1.5 (07-Jul-2026)