poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kiwiwi...@apache.org
Subject svn commit: r1693720 - /poi/trunk/src/java/org/apache/poi/sl/draw/geom/PresetGeometries.java
Date Sat, 01 Aug 2015 16:10:12 GMT
Author: kiwiwings
Date: Sat Aug  1 16:10:11 2015
New Revision: 1693720

URL: http://svn.apache.org/r1693720
Log:
Fix XmlInputFactory error of gump build

Modified:
    poi/trunk/src/java/org/apache/poi/sl/draw/geom/PresetGeometries.java

Modified: poi/trunk/src/java/org/apache/poi/sl/draw/geom/PresetGeometries.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/sl/draw/geom/PresetGeometries.java?rev=1693720&r1=1693719&r2=1693720&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/sl/draw/geom/PresetGeometries.java (original)
+++ poi/trunk/src/java/org/apache/poi/sl/draw/geom/PresetGeometries.java Sat Aug  1 16:10:11
2015
@@ -37,6 +37,7 @@ 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;
 
@@ -44,9 +45,6 @@ public class PresetGeometries extends Li
 
     @SuppressWarnings("unused")
     public void init(InputStream is) throws XMLStreamException, JAXBException {
-        // Reader xml = new InputStreamReader( is, Charset.forName("UTF-8") );
-        
-
         // StAX:
         EventFilter startElementFilter = new EventFilter() {
             @Override
@@ -55,8 +53,9 @@ public class PresetGeometries extends Li
             }
         };
         
-        long cntElem = 0;
-        XMLInputFactory staxFactory = XMLInputFactory.newInstance();
+        fixXmlSystemProperties();
+        
+        XMLInputFactory staxFactory = XMLInputFactory.newFactory();
         XMLEventReader staxReader = staxFactory.createXMLEventReader(is);
         XMLEventReader staxFiltRd = staxFactory.createFilteredReader(staxReader, startElementFilter);
         // ignore StartElement:
@@ -65,6 +64,7 @@ public class PresetGeometries extends Li
         JAXBContext jaxbContext = JAXBContext.newInstance(BINDING_PACKAGE);
         Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
 
+        long cntElem = 0;
         while (staxFiltRd.peek() != null) {
             StartElement evRoot = (StartElement)staxFiltRd.peek();
             String name = evRoot.getName().getLocalPart();
@@ -115,4 +115,21 @@ public class PresetGeometries extends Li
 
         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);
+                }
+            }
+        }
+    }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message