]> source.dussan.org Git - poi.git/commitdiff
more use of commons-io
authorPJ Fanning <fanningpj@apache.org>
Sat, 28 Aug 2021 09:13:34 +0000 (09:13 +0000)
committerPJ Fanning <fanningpj@apache.org>
Sat, 28 Aug 2021 09:13:34 +0000 (09:13 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1892670 13f79535-47bb-0310-9956-ffa450edef68

poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/internal/MemoryPackagePart.java
poi-ooxml/src/main/java/org/apache/poi/openxml4j/util/ZipArchiveFakeEntry.java
poi-ooxml/src/main/java/org/apache/poi/poifs/crypt/dsig/facets/XAdESXLSignatureFacet.java
poi-ooxml/src/main/java/org/apache/poi/xslf/draw/SVGImageRenderer.java
poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFMetroShape.java
poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFBuiltinTableStyle.java
poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFChartSheet.java

index f614b812129d9058062fb15ff077707a81e6859e..918ebbb244c451ef9d5aea0a4a0564c539240351 100644 (file)
 
 package org.apache.poi.openxml4j.opc.internal;
 
-import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 
+import org.apache.commons.io.input.UnsynchronizedByteArrayInputStream;
 import org.apache.commons.io.output.UnsynchronizedByteArrayOutputStream;
 import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
 import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
@@ -88,7 +88,7 @@ public final class MemoryPackagePart extends PackagePart {
         if (data == null) {
             data = new byte[0];
         }
-        return new ByteArrayInputStream(data);
+        return new UnsynchronizedByteArrayInputStream(data);
     }
 
     @Override
index 0709fd9021ae011d6467ec706912fa9d82810aa8..927f4035002b8c43a3f94819b673d79f3f9f3c13 100644 (file)
 
 package org.apache.poi.openxml4j.util;
 
-import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 
 import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
+import org.apache.commons.io.input.UnsynchronizedByteArrayInputStream;
 import org.apache.poi.util.IOUtils;
 
 
@@ -48,6 +48,6 @@ import org.apache.poi.util.IOUtils;
     }
 
     public InputStream getInputStream() {
-        return new ByteArrayInputStream(data);
+        return new UnsynchronizedByteArrayInputStream(data);
     }
 }
index 5a82f4152c5f3db85c72f3a5a5e398ca64d9a00f..2a1a32c5a510b98e6cb8ab894942a5152f76e48f 100644 (file)
@@ -27,7 +27,6 @@ package org.apache.poi.poifs.crypt.dsig.facets;
 import static org.apache.poi.ooxml.POIXMLTypeLoader.DEFAULT_XML_OPTIONS;
 import static org.apache.poi.poifs.crypt.dsig.facets.XAdESSignatureFacet.insertXChild;
 
-import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.math.BigInteger;
 import java.security.cert.CRLException;
@@ -46,6 +45,7 @@ import java.util.UUID;
 
 import javax.xml.crypto.MarshalException;
 
+import org.apache.commons.io.input.UnsynchronizedByteArrayInputStream;
 import org.apache.commons.io.output.UnsynchronizedByteArrayOutputStream;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
@@ -191,7 +191,7 @@ public class XAdESXLSignatureFacet implements SignatureFacet {
                 X509CRL crl;
                 try {
                     crl = (X509CRL) this.certificateFactory
-                            .generateCRL(new ByteArrayInputStream(encodedCrl));
+                            .generateCRL(new UnsynchronizedByteArrayInputStream(encodedCrl));
                 } catch (CRLException e) {
                     throw new RuntimeException("CRL parse error: "
                             + e.getMessage(), e);
index 5e2939d79fb270a8f16cab459391572b14ee9707..1e16483ea97307d6d6283d3ccb31359baf2c85bb 100644 (file)
@@ -24,7 +24,6 @@ import java.awt.geom.AffineTransform;
 import java.awt.geom.Dimension2D;
 import java.awt.geom.Rectangle2D;
 import java.awt.image.BufferedImage;
-import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.lang.ref.WeakReference;
@@ -37,6 +36,7 @@ import org.apache.batik.ext.awt.RenderingHintsKeyExt;
 import org.apache.batik.ext.awt.image.renderable.ClipRable8Bit;
 import org.apache.batik.gvt.GraphicsNode;
 import org.apache.batik.util.XMLResourceDescriptor;
+import org.apache.commons.io.input.UnsynchronizedByteArrayInputStream;
 import org.apache.poi.sl.draw.Drawable;
 import org.apache.poi.sl.draw.ImageRenderer;
 import org.apache.poi.sl.usermodel.PictureData;
@@ -68,7 +68,7 @@ public class SVGImageRenderer implements ImageRenderer {
 
     @Override
     public void loadImage(byte[] data, String contentType) throws IOException {
-        loadImage(new ByteArrayInputStream(data), contentType);
+        loadImage(new UnsynchronizedByteArrayInputStream(data), contentType);
     }
 
     @Override
index 3d06e46c4e871e7ee63a935037b7ec8480d8dbe2..69931a2e91ef5fe2fa3019642eb00bdd75079715 100644 (file)
@@ -20,9 +20,9 @@ package org.apache.poi.xslf.usermodel;
 
 import static org.apache.poi.ooxml.POIXMLTypeLoader.DEFAULT_XML_OPTIONS;
 
-import java.io.ByteArrayInputStream;
 import java.io.IOException;
 
+import org.apache.commons.io.input.UnsynchronizedByteArrayInputStream;
 import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
 import org.apache.poi.openxml4j.opc.OPCPackage;
 import org.apache.poi.openxml4j.opc.PackagePart;
@@ -46,7 +46,7 @@ public class XSLFMetroShape {
     public static Shape<?,?> parseShape(byte[] metroBytes)
     throws InvalidFormatException, IOException, XmlException {
         PackagePartName shapePN = PackagingURIHelper.createPartName("/drs/shapexml.xml");
-        try (OPCPackage pkg = OPCPackage.open(new ByteArrayInputStream(metroBytes))) {
+        try (OPCPackage pkg = OPCPackage.open(new UnsynchronizedByteArrayInputStream(metroBytes))) {
             PackagePart shapePart = pkg.getPart(shapePN);
             CTGroupShape gs = CTGroupShape.Factory.parse(shapePart.getInputStream(), DEFAULT_XML_OPTIONS);
             XSLFGroupShape xgs = new XSLFGroupShape(gs, null);
index 836410872301b4a695737fccacbc9a202af52f22..d496774bf5650b14cd589aaa13babfae1d4bc4c2 100644 (file)
@@ -17,7 +17,6 @@
 
 package org.apache.poi.xssf.usermodel;
 
-import java.io.ByteArrayInputStream;
 import java.io.InputStream;
 import java.nio.charset.StandardCharsets;
 import java.util.EnumMap;
@@ -29,6 +28,7 @@ import javax.xml.transform.TransformerException;
 import javax.xml.transform.dom.DOMSource;
 import javax.xml.transform.stream.StreamResult;
 
+import org.apache.commons.io.input.UnsynchronizedByteArrayInputStream;
 import org.apache.commons.io.output.StringBuilderWriter;
 import org.apache.poi.ooxml.util.DocumentHelper;
 import org.apache.poi.ss.usermodel.DifferentialStyleProvider;
@@ -410,7 +410,7 @@ public enum XSSFBuiltinTableStyle {
                     // hack because I can't figure out how to get XMLBeans to parse a sub-element in a standalone manner
                     // - build a fake styles.xml file with just this built-in
                     StylesTable styles = new StylesTable();
-                    styles.readFrom(new ByteArrayInputStream(styleXML(dxfsNode, tableStyleNode).getBytes(StandardCharsets.UTF_8)));
+                    styles.readFrom(new UnsynchronizedByteArrayInputStream(styleXML(dxfsNode, tableStyleNode).getBytes(StandardCharsets.UTF_8)));
                     styleMap.put(builtIn, new XSSFBuiltinTypeStyleStyle(builtIn, styles.getExplicitTableStyle(styleName)));
                 }
             } finally {
index 6aa3c9f5799759d9eb4362acd77eabfffa08a49d..bbd8c261b4299a3c222ee78f41a8f74a7b93333d 100644 (file)
@@ -19,13 +19,13 @@ package org.apache.poi.xssf.usermodel;
 
 import static org.apache.poi.ooxml.POIXMLTypeLoader.DEFAULT_XML_OPTIONS;
 
-import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 
 import javax.xml.namespace.QName;
 
+import org.apache.commons.io.input.UnsynchronizedByteArrayInputStream;
 import org.apache.commons.io.output.UnsynchronizedByteArrayOutputStream;
 import org.apache.poi.ooxml.POIXMLException;
 import org.apache.poi.openxml4j.opc.PackagePart;
@@ -57,7 +57,7 @@ public class XSSFChartSheet extends XSSFSheet  {
     @Override
     protected void read(InputStream is) throws IOException {
         //initialize the supeclass with a blank worksheet
-        super.read(new ByteArrayInputStream(BLANK_WORKSHEET));
+        super.read(new UnsynchronizedByteArrayInputStream(BLANK_WORKSHEET));
 
         try {
             chartsheet = ChartsheetDocument.Factory.parse(is, DEFAULT_XML_OPTIONS).getChartsheet();