RFR: JDK-8008738 - Issue in com.sun.org.apache.xml.internal.serializer.Encodings causes some JCK tests to fail intermittently (original) (raw)
Daniel Fuchs daniel.fuchs at oracle.com
Mon Apr 15 14:09:24 UTC 2013
- Previous message: 8012237: CompletableFuture/Basic.java still fails intermittently
- Next message: RFR: JDK-8008738 - Issue in com.sun.org.apache.xml.internal.serializer.Encodings causes some JCK tests to fail intermittently
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi,
This a fix for:
JDK-8008738 - Issue in com.sun.org.apache.xml.internal.serializer.Encodings causes some JCK tests to fail intermittently.
<http://cr.openjdk.java.net/~dfuchs/JDK-8008738/webrev.02/>
The issue here is that com.sun.org.apache.xml.internal.serializer.Encodings tries to implement a double mapping:
Java Charset Name => Preferred XML Mime Name
and
XML Mime Name => Java Charset Name
from a specification that it reads from an Encoding.properties file.
However, there can be several 'Java' names (aliases) corresponding to a given Charset, and there could also be several XML Mime Names, corresponding to that same charset.
The Encodings.properties files uses 'Java Names' as keys, which it can map to one - or more - XML mime names, where the first XML name in the list stands for the 'preferred' mime name.
The trouble is that some of the Java names present in the Encodings.properties files are not recognized by the Charset API, although some of the corresponding XML mime names, can be.
This resulted in the creation of EncodingInfo objects whose charset name was not recognized by the Charset API. However, since there can be several Java Names specified with the same XML name, this did not always lead to errors: when 'converting' an XML name to a Java Name, if the first mapping picked up had a recognized Java Name - everything went well. If however - the first mapping picked up had an unrecognized Java Name, then this lead to failure to encode characters properly. Since the order in which the EncodingInfo where registered depended on the order of keys/values returned by HashMap/Properties - it could work in one run and fail in another.
The proposed changeset is reworking the algorithm that creates EncodingInfo objects and perform the mapping Java Name <-> Mime Name:
- Parse the whole line and consider both Java Names & Mime Names when trying to instantiate EncodingInfo objects for a Java Name,
- Make sure the javaName recorded in EncodingInfo is one that is recognized by Charset.forName().
The changeset has a unit test (under jdk/test/javax/xml/jaxp) which
verifies that the Encodings.properties file has no inconsistencies
verifies the mapping implemented by Encodings.java - by calling Encodings.convertMime2JavaEncoding() and Encodings.getMimeEncoding() (skipping those names for which no charset could be loaded, as not all charset are necessarily available on all machines).
-- daniel
- Previous message: 8012237: CompletableFuture/Basic.java still fails intermittently
- Next message: RFR: JDK-8008738 - Issue in com.sun.org.apache.xml.internal.serializer.Encodings causes some JCK tests to fail intermittently
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]