Skip to content

[TCK] Tests incorrectly assumes that Charset.defaultCharset() is always UTF-8 #348

Closed

Description

@KyleAure

When running the TCK on an OS/JDK combination that uses a different character encoding other than UTF-8 the following tests fail:

<testcase classname="ee.jakarta.tck.json.bind.api.jsonb.JsonbTest" name="testFromJsonReaderClass" time="0.001">
<testcase classname="ee.jakarta.tck.json.bind.api.jsonb.JsonbTest" name="testToJsonObjectTypeWriter" time="0.001">
<testcase classname="ee.jakarta.tck.json.bind.api.jsonb.JsonbTest" name="testFromJsonReaderType" time="0">
<testcase classname="ee.jakarta.tck.json.bind.api.jsonb.JsonbTest" name="testToJsonObjectWriter" time="0.001">
<testcase classname="ee.jakarta.tck.json.bind.customizedmapping.binarydata.BinaryDataCustomizationTest" name="testBase64UrlBinaryDataEncoding" time="0.016">
<testcase classname="ee.jakarta.tck.json.bind.customizedmapping.binarydata.BinaryDataCustomizationTest" name="testByteBinaryDataEncoding" time="0.002">
<testcase classname="ee.jakarta.tck.json.bind.customizedmapping.binarydata.BinaryDataCustomizationTest" name="testBase64BinaryDataEncoding" time="0.001">
<testcase classname="ee.jakarta.tck.json.bind.customizedmapping.ijson.IJsonSupportTest" name="testStrictNonObjectOrArrayTopLevel" time="0.002">
<testcase classname="ee.jakarta.tck.json.bind.customizedmapping.ijson.IJsonSupportTest" name="testStrictBinaryDataEncoding" time="0.001">
<testcase classname="ee.jakarta.tck.json.bind.defaultmapping.basictypes.BasicJavaTypesMappingTest" name="testNumberMapping" time="0.001">
<testcase classname="ee.jakarta.tck.json.bind.defaultmapping.specifictypes.SpecificTypesMappingTest" name="testEmptyOptionalDoubleMapping" time="0.002">
<testcase classname="ee.jakarta.tck.json.bind.defaultmapping.specifictypes.SpecificTypesMappingTest" name="testEmptyOptionalMapping" time="0.002">
<testcase classname="ee.jakarta.tck.json.bind.defaultmapping.specifictypes.SpecificTypesMappingTest" name="testEmptyOptionalArrayMapping" time="0.002">
<testcase classname="ee.jakarta.tck.json.bind.defaultmapping.specifictypes.SpecificTypesMappingTest" name="testEmptyOptionalLongMapping" time="0.002">
<testcase classname="ee.jakarta.tck.json.bind.defaultmapping.specifictypes.SpecificTypesMappingTest" name="testEmptyOptionalIntMapping" time="0.001">
<testcase classname="ee.jakarta.tck.json.bind.defaultmapping.specifictypes.SpecificTypesMappingTest" name="testOptionalObjectMapping" time="0.002">

Due to assertions that assume that Charset.defaultCharset() will return UTF-8.
For example (testToJsonObjectTypeWriter) fails with the following when run on z/OS with a default character encoding of IBM-1047:

Failed to marshal using Jsonb.toJson method with Object, Type and Writer arguments.
Expected: a string matching the pattern '\{\s*"instance"\s*:\s*"Test"\s*}'
but: was "�����������z�ㅢ���"
at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
at ee.jakarta.tck.json.bind.api.jsonb.JsonbTest.testToJsonObjectTypeWriter(JsonbTest.java:221) 

If we look at this test:
https://github.com/jakartaee/jsonb-api/blob/master/tck/src/main/java/ee/jakarta/tck/json/bind/api/jsonb/JsonbTest.java#L215-L224

new OutputStreamWriter(stream) will return a Writer with a character encoding of IBM-1047.
Then we try to create a string where the bytes are encoded using IBM-1047 but we decode it using UTF-8 resulting in:
�����������z�ㅢ���

Activity

  1. added this to the 3.1 milestone on Aug 7, 2026
  2. added
    bug
    on Aug 12, 2026
  3. modified the milestones: 3.1, 3.0.3 on Aug 12, 2026
  4. self-assigned this
    on Aug 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

TCKbug

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions