Skip to content

Commit b5c92ca

Browse files
y1yang0robcasloz
authored andcommittedApr 21, 2021
8265106: IGV: Enforce en-US locale while parsing ideal graph
Co-authored-by: Roberto Castañeda Lozano <rcastanedalo@openjdk.org> Reviewed-by: thartmann, chagedorn
1 parent 3de0dcb commit b5c92ca

File tree

2 files changed

+9
-0
lines changed
  • src/utils/IdealGraphVisualizer/Data/src

2 files changed

+9
-0
lines changed
 

‎src/utils/IdealGraphVisualizer/Data/src/main/java/com/sun/hotspot/igv/data/serialization/Parser.java

+3
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import java.nio.channels.ReadableByteChannel;
3535
import java.util.ArrayList;
3636
import java.util.HashMap;
37+
import java.util.Locale;
3738
import java.util.Map;
3839
import javax.swing.SwingUtilities;
3940
import javax.xml.parsers.ParserConfigurationException;
@@ -529,6 +530,8 @@ public GraphDocument parse() throws IOException {
529530
}
530531
try {
531532
XMLReader reader = createReader();
533+
// To enforce using English for non-English users, we must use Locale.ROOT rather than Locale.ENGLISH
534+
reader.setProperty("http://apache.org/xml/properties/locale", Locale.ROOT);
532535
reader.setContentHandler(new XMLParser(xmlDocument, monitor));
533536
reader.parse(new InputSource(Channels.newInputStream(channel)));
534537
} catch (SAXException ex) {

‎src/utils/IdealGraphVisualizer/Data/src/test/java/com/sun/hotspot/igv/data/serialization/ParserTest.java

+6
Original file line numberDiff line numberDiff line change
@@ -222,4 +222,10 @@ public void testParse() {
222222
testBoth(new GraphDocument(), "<graphDocument></graphDocument>");
223223
}
224224

225+
@Test
226+
public void testParseIncompleteXML() {
227+
// Exception should be swallowed, see catch clause in GraphParser.parse.
228+
testBoth(new GraphDocument(), "<graphDocument>");
229+
}
230+
225231
}

0 commit comments

Comments
 (0)
Please sign in to comment.