[platform] resets XML input factory key to original value after factory instantiation (IDEA-206607)

This commit is contained in:
Roman Shevchenko
2019-02-06 10:51:32 +01:00
parent 18008452b5
commit 962b93076f
@@ -41,13 +41,22 @@ public class JDOMUtil {
}
};
private static final String XML_INPUT_FACTORY_KEY = "javax.xml.stream.XMLInputFactory";
private static final String XML_INPUT_FACTORY_IMPL = "com.sun.xml.internal.stream.XMLInputFactoryImpl";
private static final NotNullLazyValue<XMLInputFactory> XML_INPUT_FACTORY = new NotNullLazyValue<XMLInputFactory>() {
@NotNull
@Override
protected XMLInputFactory compute() {
// requests default JRE factory implementation instead of an incompatible one from the classpath
System.setProperty("javax.xml.stream.XMLInputFactory", "com.sun.xml.internal.stream.XMLInputFactoryImpl");
XMLInputFactory factory = XMLInputFactory.newFactory();
String property = System.setProperty(XML_INPUT_FACTORY_KEY, XML_INPUT_FACTORY_IMPL);
XMLInputFactory factory;
try {
factory = XMLInputFactory.newFactory();
}
finally {
if (property != null) System.setProperty(XML_INPUT_FACTORY_KEY, property);
else System.clearProperty(XML_INPUT_FACTORY_KEY);
}
if (!SystemInfo.isIbmJvm) {
try {
factory.setProperty("http://java.sun.com/xml/stream/properties/report-cdata-event", true);