-
Bug
-
Resolution: Fixed
-
P3
-
None
-
b17
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8299647 | 11.0.19-oracle | Ramesh Gangadhar | P3 | Resolved | Fixed | b01 |
JDK-8302724 | 11.0.19 | Goetz Lindenmaier | P3 | Resolved | Fixed | b03 |
JDK-8334749 | 8u431 | Hari Rakesh | P3 | Resolved | Fixed | b01 |
https://github.com/openjdk/jdk/blob/master/test/jdk/java/util/prefs/ExportNode.java#L50
[from linked bug report]
This testcase creates a simple tree of two nodes N1 and N2, where N2 is the
descendant of N1, and adds a key-value pair each on both. N2 is then exported
to a ByteArrayOutputStream using the exportNode() method.
Now, the contract of the exportNode() method makes it clear that it "Emits on
the specified output stream an XML document.... The UTF-8 character encoding
will be used."
So, the ByteArrayOutputStream is going to hold the UTF-8 bytes of the XML
representation of the given node. We subsequently call toString() on it and
make some elementary searches. Here, ByteArrayOutputStream.toString() is
going to use the platforms default charset to wrap the bytes into a String.
On non-ASCII platforms, like z/OS, we'd end up building a String with a
non-UTF8 charset and UTF-8 bytes. This mismatch causes failure.
Proposed fix:
To make the test resilient to non-ASCII platforms as well, we'd suggest that
ByteArrayOutputStream be called with the charset name of "UTF-8" as in
exportStream.toString("UTF-8").
[from linked bug report]
This testcase creates a simple tree of two nodes N1 and N2, where N2 is the
descendant of N1, and adds a key-value pair each on both. N2 is then exported
to a ByteArrayOutputStream using the exportNode() method.
Now, the contract of the exportNode() method makes it clear that it "Emits on
the specified output stream an XML document.... The UTF-8 character encoding
will be used."
So, the ByteArrayOutputStream is going to hold the UTF-8 bytes of the XML
representation of the given node. We subsequently call toString() on it and
make some elementary searches. Here, ByteArrayOutputStream.toString() is
going to use the platforms default charset to wrap the bytes into a String.
On non-ASCII platforms, like z/OS, we'd end up building a String with a
non-UTF8 charset and UTF-8 bytes. This mismatch causes failure.
Proposed fix:
To make the test resilient to non-ASCII platforms as well, we'd suggest that
ByteArrayOutputStream be called with the charset name of "UTF-8" as in
exportStream.toString("UTF-8").
- backported by
-
JDK-8299647 jdk/test/jdk/java/util/prefs/ExportNode.java relies on default platform encoding
-
- Resolved
-
-
JDK-8302724 jdk/test/jdk/java/util/prefs/ExportNode.java relies on default platform encoding
-
- Resolved
-
-
JDK-8334749 jdk/test/jdk/java/util/prefs/ExportNode.java relies on default platform encoding
-
- Resolved
-
- links to
-
Commit openjdk/jdk11u-dev/ffac38fc
-
Commit openjdk/jdk/104e925d
-
Review openjdk/jdk11u-dev/1755
-
Review openjdk/jdk/3332
(2 links to)