aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/java/org/apache/poi/sl/draw/geom/PresetGeometries.java31
-rw-r--r--src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestPPTX2PNG.java20
2 files changed, 16 insertions, 35 deletions
diff --git a/src/java/org/apache/poi/sl/draw/geom/PresetGeometries.java b/src/java/org/apache/poi/sl/draw/geom/PresetGeometries.java
index e338ec91c5..c3a9361e4e 100644
--- a/src/java/org/apache/poi/sl/draw/geom/PresetGeometries.java
+++ b/src/java/org/apache/poi/sl/draw/geom/PresetGeometries.java
@@ -22,8 +22,15 @@ package org.apache.poi.sl.draw.geom;
import java.io.InputStream;
import java.util.LinkedHashMap;
-import javax.xml.bind.*;
-import javax.xml.stream.*;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.stream.EventFilter;
+import javax.xml.stream.XMLEventReader;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.events.StartElement;
import javax.xml.stream.events.XMLEvent;
@@ -37,7 +44,6 @@ import org.apache.poi.util.POILogger;
public class PresetGeometries extends LinkedHashMap<String, CustomGeometry> {
private final static POILogger LOG = POILogFactory.getLogger(PresetGeometries.class);
protected final static String BINDING_PACKAGE = "org.apache.poi.sl.draw.binding";
- private static final String JAXPFACTORYID = "javax.xml.stream.XMLInputFactory";
protected static PresetGeometries _inst;
@@ -53,8 +59,6 @@ public class PresetGeometries extends LinkedHashMap<String, CustomGeometry> {
}
};
- fixXmlSystemProperties();
-
XMLInputFactory staxFactory = XMLInputFactory.newFactory();
XMLEventReader staxReader = staxFactory.createXMLEventReader(is);
XMLEventReader staxFiltRd = staxFactory.createFilteredReader(staxReader, startElementFilter);
@@ -115,21 +119,4 @@ public class PresetGeometries extends LinkedHashMap<String, CustomGeometry> {
return _inst;
}
-
- public static void fixXmlSystemProperties() {
- // handling for illegal system properties - mainly because of failing gump build
- String xmlFactClass = System.getProperty(JAXPFACTORYID);
- if (xmlFactClass != null) {
- try {
- Class.forName(xmlFactClass);
- } catch (Exception e) {
- LOG.log(POILogger.ERROR, "Invalid xml input factory config detected. ("+JAXPFACTORYID+"="+xmlFactClass+")");
- try {
- System.clearProperty(JAXPFACTORYID);
- } catch (Exception e2) {
- LOG.log(POILogger.ERROR, "Failed to remove invalid xml input factory", e2);
- }
- }
- }
- }
}
diff --git a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestPPTX2PNG.java b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestPPTX2PNG.java
index fc7747d7ee..ecf6457bbe 100644
--- a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestPPTX2PNG.java
+++ b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestPPTX2PNG.java
@@ -26,8 +26,6 @@ import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;
-import javax.xml.stream.XMLInputFactory;
-
import org.apache.poi.sl.draw.Drawable;
import org.apache.poi.util.JvmBugs;
import org.apache.poi.xslf.XSLFTestDataSamples;
@@ -46,7 +44,7 @@ public class TestPPTX2PNG {
@BeforeClass
public static void activateJaxpDebug() {
jaxpDebugEnable = setDebugFld(true);
- fixDefaultInputFactory();
+ setXmlInputFactory();
}
@AfterClass
@@ -69,17 +67,13 @@ public class TestPPTX2PNG {
}
}
- private static void fixDefaultInputFactory() {
- String originalValue = "com.sun.xml.internal.stream.XMLInputFactoryImpl";
+ private static void setXmlInputFactory() {
+ String propName = "javax.xml.stream.XMLInputFactory";
+ String propVal = "com.sun.xml.internal.stream.XMLInputFactoryImpl";
try {
- Field fld = XMLInputFactory.class.getDeclaredField("DEFAULIMPL");
- fld.setAccessible(true);
- String val = (String)fld.get(null);
- if (!originalValue.equals(val)) {
- System.out.println("DefaultXMLInputFactory illegal changed to: "+val);
- fld.set(null, originalValue);
- }
- } catch (Exception e) {
+ Class.forName(propVal);
+ System.setProperty(propName, propVal);
+ } catch (Exception e){
// ignore
}
}