poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kiwiwi...@apache.org
Subject svn commit: r1848494 - in /poi: site/src/documentation/content/xdocs/changes.xml trunk/src/java/org/apache/poi/sl/draw/geom/PresetGeometries.java
Date Sun, 09 Dec 2018 02:08:50 GMT
Author: kiwiwings
Date: Sun Dec  9 02:08:50 2018
New Revision: 1848494

URL: http://svn.apache.org/viewvc?rev=1848494&view=rev
Log:
#62966 - init presetShapeDefinitions.xml fail under IBM jdk

Modified:
    poi/site/src/documentation/content/xdocs/changes.xml
    poi/trunk/src/java/org/apache/poi/sl/draw/geom/PresetGeometries.java

Modified: poi/site/src/documentation/content/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/poi/site/src/documentation/content/xdocs/changes.xml?rev=1848494&r1=1848493&r2=1848494&view=diff
==============================================================================
--- poi/site/src/documentation/content/xdocs/changes.xml (original)
+++ poi/site/src/documentation/content/xdocs/changes.xml Sun Dec  9 02:08:50 2018
@@ -87,6 +87,7 @@
 
     <release version="4.0.2" date="2019-02-??">
       <actions>
+        <action dev="PD" type="fix" fixes-bug="62966" context="SL_Common">init presetShapeDefinitions.xml
fail under IBM jdk</action>
         <action dev="PD" type="fix" fixes-bug="62953" context="SL_Common XSLF HSLF">Rendering
of FreeformShapes with formula fails</action>
       </actions>
     </release>

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=1848494&r1=1848493&r2=1848494&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 Sun Dec  9 02:08:50
2018
@@ -27,12 +27,12 @@ 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.XMLStreamConstants;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;
-import javax.xml.stream.events.StartElement;
 import javax.xml.stream.events.XMLEvent;
+import javax.xml.transform.stream.StreamSource;
 
 import org.apache.poi.sl.draw.binding.CTCustomGeometry2D;
 import org.apache.poi.util.POILogFactory;
@@ -61,27 +61,30 @@ public class PresetGeometries extends Li
         };
         
         XMLInputFactory staxFactory = StaxHelper.newXMLInputFactory();
-        XMLEventReader staxReader = staxFactory.createXMLEventReader(is);
-        XMLEventReader staxFiltRd = staxFactory.createFilteredReader(staxReader, startElementFilter);
-        // ignore StartElement:
-        /* XMLEvent evDoc = */ staxFiltRd.nextEvent();
-        // JAXB:
-        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();
-            JAXBElement<CTCustomGeometry2D> el = unmarshaller.unmarshal(staxReader,
CTCustomGeometry2D.class);
-            CTCustomGeometry2D cus = el.getValue();
-            cntElem++;
-            
-            if(containsKey(name)) {
-                LOG.log(POILogger.WARN, "Duplicate definition of " + name);
+        XMLStreamReader streamReader = staxFactory.createXMLStreamReader(new StreamSource(is));
+        try {
+            // ignore StartElement:
+            streamReader.nextTag();
+
+            // JAXB:
+            JAXBContext jaxbContext = JAXBContext.newInstance(BINDING_PACKAGE);
+            Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
+
+            long cntElem = 0;
+            while (streamReader.hasNext() && streamReader.nextTag() == XMLStreamConstants.START_ELEMENT)
{
+                String name = streamReader.getLocalName();
+                JAXBElement<CTCustomGeometry2D> el = unmarshaller.unmarshal(streamReader,
CTCustomGeometry2D.class);
+                CTCustomGeometry2D cus = el.getValue();
+                cntElem++;
+
+                if (containsKey(name)) {
+                    LOG.log(POILogger.WARN, "Duplicate definition of " + name);
+                }
+                put(name, new CustomGeometry(cus));
             }
-            put(name, new CustomGeometry(cus));
-        }       
+        } finally {
+            streamReader.close();
+        }
     }
     
     /**



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


Mime
View raw message