mirror of https://github.com/apache/poi.git
Fix XmlInputFactory error of gump build
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1693720 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
10611e04ac
commit
bc1d4f59b0
|
@ -37,6 +37,7 @@ import org.apache.poi.util.POILogger;
|
||||||
public class PresetGeometries extends LinkedHashMap<String, CustomGeometry> {
|
public class PresetGeometries extends LinkedHashMap<String, CustomGeometry> {
|
||||||
private final static POILogger LOG = POILogFactory.getLogger(PresetGeometries.class);
|
private final static POILogger LOG = POILogFactory.getLogger(PresetGeometries.class);
|
||||||
protected final static String BINDING_PACKAGE = "org.apache.poi.sl.draw.binding";
|
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;
|
protected static PresetGeometries _inst;
|
||||||
|
|
||||||
|
@ -44,9 +45,6 @@ public class PresetGeometries extends LinkedHashMap<String, CustomGeometry> {
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public void init(InputStream is) throws XMLStreamException, JAXBException {
|
public void init(InputStream is) throws XMLStreamException, JAXBException {
|
||||||
// Reader xml = new InputStreamReader( is, Charset.forName("UTF-8") );
|
|
||||||
|
|
||||||
|
|
||||||
// StAX:
|
// StAX:
|
||||||
EventFilter startElementFilter = new EventFilter() {
|
EventFilter startElementFilter = new EventFilter() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -55,8 +53,9 @@ public class PresetGeometries extends LinkedHashMap<String, CustomGeometry> {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
long cntElem = 0;
|
fixXmlSystemProperties();
|
||||||
XMLInputFactory staxFactory = XMLInputFactory.newInstance();
|
|
||||||
|
XMLInputFactory staxFactory = XMLInputFactory.newFactory();
|
||||||
XMLEventReader staxReader = staxFactory.createXMLEventReader(is);
|
XMLEventReader staxReader = staxFactory.createXMLEventReader(is);
|
||||||
XMLEventReader staxFiltRd = staxFactory.createFilteredReader(staxReader, startElementFilter);
|
XMLEventReader staxFiltRd = staxFactory.createFilteredReader(staxReader, startElementFilter);
|
||||||
// ignore StartElement:
|
// ignore StartElement:
|
||||||
|
@ -65,6 +64,7 @@ public class PresetGeometries extends LinkedHashMap<String, CustomGeometry> {
|
||||||
JAXBContext jaxbContext = JAXBContext.newInstance(BINDING_PACKAGE);
|
JAXBContext jaxbContext = JAXBContext.newInstance(BINDING_PACKAGE);
|
||||||
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
|
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
|
||||||
|
|
||||||
|
long cntElem = 0;
|
||||||
while (staxFiltRd.peek() != null) {
|
while (staxFiltRd.peek() != null) {
|
||||||
StartElement evRoot = (StartElement)staxFiltRd.peek();
|
StartElement evRoot = (StartElement)staxFiltRd.peek();
|
||||||
String name = evRoot.getName().getLocalPart();
|
String name = evRoot.getName().getLocalPart();
|
||||||
|
@ -115,4 +115,21 @@ public class PresetGeometries extends LinkedHashMap<String, CustomGeometry> {
|
||||||
|
|
||||||
return _inst;
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue