diff --git a/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/internal/MemoryPackagePart.java b/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/internal/MemoryPackagePart.java index f614b81212..918ebbb244 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/internal/MemoryPackagePart.java +++ b/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/internal/MemoryPackagePart.java @@ -17,11 +17,11 @@ 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 diff --git a/poi-ooxml/src/main/java/org/apache/poi/openxml4j/util/ZipArchiveFakeEntry.java b/poi-ooxml/src/main/java/org/apache/poi/openxml4j/util/ZipArchiveFakeEntry.java index 0709fd9021..927f403500 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/openxml4j/util/ZipArchiveFakeEntry.java +++ b/poi-ooxml/src/main/java/org/apache/poi/openxml4j/util/ZipArchiveFakeEntry.java @@ -17,11 +17,11 @@ 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); } } diff --git a/poi-ooxml/src/main/java/org/apache/poi/poifs/crypt/dsig/facets/XAdESXLSignatureFacet.java b/poi-ooxml/src/main/java/org/apache/poi/poifs/crypt/dsig/facets/XAdESXLSignatureFacet.java index 5a82f4152c..2a1a32c5a5 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/poifs/crypt/dsig/facets/XAdESXLSignatureFacet.java +++ b/poi-ooxml/src/main/java/org/apache/poi/poifs/crypt/dsig/facets/XAdESXLSignatureFacet.java @@ -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); diff --git a/poi-ooxml/src/main/java/org/apache/poi/xslf/draw/SVGImageRenderer.java b/poi-ooxml/src/main/java/org/apache/poi/xslf/draw/SVGImageRenderer.java index 5e2939d79f..1e16483ea9 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xslf/draw/SVGImageRenderer.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xslf/draw/SVGImageRenderer.java @@ -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 diff --git a/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFMetroShape.java b/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFMetroShape.java index 3d06e46c4e..69931a2e91 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFMetroShape.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFMetroShape.java @@ -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); diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFBuiltinTableStyle.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFBuiltinTableStyle.java index 8364108723..d496774bf5 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFBuiltinTableStyle.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFBuiltinTableStyle.java @@ -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 { diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFChartSheet.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFChartSheet.java index 6aa3c9f579..bbd8c261b4 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFChartSheet.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFChartSheet.java @@ -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();