From 962b93076fc8120a53b658c45b07be81902f0fdc Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Wed, 6 Feb 2019 10:51:13 +0100 Subject: [PATCH] [platform] resets XML input factory key to original value after factory instantiation (IDEA-206607) --- .../src/com/intellij/openapi/util/JDOMUtil.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/platform/util/src/com/intellij/openapi/util/JDOMUtil.java b/platform/util/src/com/intellij/openapi/util/JDOMUtil.java index 3a83ca321666..2c1ab6288f2d 100644 --- a/platform/util/src/com/intellij/openapi/util/JDOMUtil.java +++ b/platform/util/src/com/intellij/openapi/util/JDOMUtil.java @@ -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 XML_INPUT_FACTORY = new NotNullLazyValue() { @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);