Skip to content

Add NonBlockingByteBufferParser tests for JSON-escaped surrogate pairs in field names (#1581)#1582

Merged
cowtowncoder merged 3 commits into3.xfrom
copilot/fix-issue-1581
Mar 27, 2026
Merged

Add NonBlockingByteBufferParser tests for JSON-escaped surrogate pairs in field names (#1581)#1582
cowtowncoder merged 3 commits into3.xfrom
copilot/fix-issue-1581

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 26, 2026

NonBlockingByteBufferParser was reported to throw Invalid UTF-8: Illegal surrogate character when parsing field names containing JSON-escaped surrogate pairs (e.g. {"\\uD834\\uDd1e": 1}), while the same input worked correctly in string values and in the NonBlockingByteArrayParser.

The fix from #1541 was correctly applied to NonBlockingUtf8JsonParserBase._parseEscapedName, which is shared by both NonBlockingByteArrayParser and NonBlockingByteBufferParser via inheritance. The gap was test coverage: AsyncEscapedSurrogateInFieldName1541Test only exercised the ByteArray parser via asyncForBytes(), never the ByteBuffer parser via asyncForByteBuffer().

Changes

  • New test class AsyncByteBufferEscapedSurrogateInFieldName1581Test mirrors the ByteArray coverage in AsyncEscapedSurrogateInFieldName1541Test for the NonBlockingByteBufferParser, covering:
    • Chunk sizes of 1, 2, 3, 7, and 100 bytes — exercising both the split-escape slow path (_finishPropertyWithEscape) and the inline fast path
    • Regular double-quoted and apostrophe-quoted field names
    • Name variations across quad-boundary alignments, multiple consecutive surrogate pairs, and long names (>12 bytes)
    • Error cases: lone high surrogate and lone low surrogate

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • central.sonatype.com
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --enable-native-access=ALL-UNNAMED -classpath /usr/share/apache-maven-3.9.13/boot/plexus-classworlds-2.9.0.jar -Dclassworlds.conf=/usr/share/apache-maven-3.9.13/bin/m2.conf -Dmaven.home=/usr/share/apache-maven-3.9.13 -Dlibrary.jansi.path=/usr/share/apache-maven-3.9.13/lib/jansi-native -Dmaven.multiModuleProjectDirectory=/home/REDACTED/work/jackson-core/jackson-core org.codehaus.plexus.classworlds.launcher.Launcher test -pl . -Dtest=AsyncEscapedSurrogateInFieldName1541Test -q (dns block)
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --enable-native-access=ALL-UNNAMED -classpath /home/REDACTED/.m2/wrapper/dists/apache-maven-3.9.11/a2d47e15/boot/plexus-classworlds-2.9.0.jar -Dclassworlds.conf=/home/REDACTED/.m2/wrapper/dists/apache-maven-3.9.11/a2d47e15/bin/m2.conf -Dmaven.home=/home/REDACTED/.m2/wrapper/dists/apache-maven-3.9.11/a2d47e15 -Dlibrary.jansi.path=/home/REDACTED/.m2/wrapper/dists/apache-maven-3.9.11/a2d47e15/lib/jansi-native -Dmaven.multiModuleProjectDirectory=/home/REDACTED/work/jackson-core/jackson-core org.codehaus.plexus.classworlds.launcher.Launcher test -Dtest=AsyncEscapedSurrogateInFieldName1541Test -q (dns block)
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --enable-native-access=ALL-UNNAMED -classpath /usr/share/apache-maven-3.9.13/boot/plexus-classworlds-2.9.0.jar -Dclassworlds.conf=/usr/share/apache-maven-3.9.13/bin/m2.conf -Dmaven.home=/usr/share/apache-maven-3.9.13 -Dlibrary.jansi.path=/usr/share/apache-maven-3.9.13/lib/jansi-native -Dmaven.multiModuleProjectDirectory=/home/REDACTED/work/jackson-core/jackson-core org.codehaus.plexus.classworlds.launcher.Launcher test -Dtest=AsyncEscapedSurrogateInFieldName1541Test -Dmaven.parent.skip=true -q (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.

Copilot AI changed the title [WIP] Fix issue 1581 in jackson-core Add NonBlockingByteBufferParser tests for JSON-escaped surrogate pairs in field names (#1581) Mar 26, 2026
Copilot AI requested a review from pjfanning March 26, 2026 18:23
@pjfanning
Copy link
Copy Markdown
Member

I'll look into retargeting this at 2.21 branch to add regression testing and to see if there is an issue that exists only in the 2.x branches.

@cowtowncoder
Copy link
Copy Markdown
Member

@pjfanning Yes: #1567 only covers blocking parser, limited and not covering async variant(s).

@github-actions
Copy link
Copy Markdown

📈 Overall Code Coverage

Metric Coverage Change
Instructions coverage 83.07% 📈 +0.020%
Branches branches 75.74% 📈 +0.030%

Overall project coverage from JaCoCo test results. Change values compare against the latest base branch build.

@cowtowncoder
Copy link
Copy Markdown
Member

cowtowncoder commented Mar 27, 2026

@pjfanning I could also just merge this in 3.x for improved code coverage? Let me know if that makes sense -- leaving as-is for now.

@pjfanning pjfanning marked this pull request as ready for review March 27, 2026 20:59
@pjfanning
Copy link
Copy Markdown
Member

@cowtowncoder merge it in 3.x or 3.1 for the extra coverage.

#1583 is the 2.21 equivalent but it fails. I got Copilot to draft a proposal for a fix.

@cowtowncoder cowtowncoder merged commit 2a0054a into 3.x Mar 27, 2026
6 checks passed
@cowtowncoder cowtowncoder deleted the copilot/fix-issue-1581 branch March 27, 2026 21:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants