aboutsummaryrefslogtreecommitdiffstats
path: root/poi-scratchpad
diff options
context:
space:
mode:
authorDominik Stadler <centic@apache.org>2023-06-08 08:53:08 +0000
committerDominik Stadler <centic@apache.org>2023-06-08 08:53:08 +0000
commitd3e35e740a593027a1105e6509c0aadaa54399b0 (patch)
tree4f9c5b276aa7a088def6aaa7282bb37c39b16105 /poi-scratchpad
parentc8f9fe4c2c01aa896c80de7b43725788b4ce6c4a (diff)
downloadpoi-d3e35e740a593027a1105e6509c0aadaa54399b0.tar.gz
poi-d3e35e740a593027a1105e6509c0aadaa54399b0.zip
Remove deprecation warnings reported with newer commons-io
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1910300 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi-scratchpad')
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/extractor/ole2/OLE2ScratchpadExtractorFactory.java7
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hdgf/HDGFLZW.java2
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hdgf/streams/CompressedStreamStore.java2
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hemf/draw/HemfImageRenderer.java2
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hemf/record/emf/HemfFill.java2
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hemf/record/emfplus/HemfPlusBrush.java4
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hemf/record/emfplus/HemfPlusImage.java6
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hemf/usermodel/HemfEmbeddedIterator.java4
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hmef/attribute/MAPIAttribute.java2
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hmef/attribute/MAPIRtfAttribute.java2
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hpbf/model/HPBFPart.java2
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hslf/blip/Bitmap.java2
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hslf/blip/EMF.java4
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hslf/blip/Metafile.java4
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hslf/blip/PICT.java6
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hslf/blip/WMF.java4
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hslf/dev/PPTXMLDump.java2
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hslf/dev/SlideIdListing.java2
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hslf/dev/SlideShowRecordDumper.java6
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hslf/dev/UserEditAndPersistListing.java4
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hslf/model/textproperties/TextPropCollection.java2
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ColorSchemeAtom.java2
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hslf/record/CurrentUserAtom.java2
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hslf/record/EscherTextboxWrapper.java2
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ExOleObjStg.java2
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hslf/record/HSLFEscherClientDataRecord.java2
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hslf/record/PPDrawingGroup.java4
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hslf/record/RecordContainer.java2
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hslf/record/StyleTextPropAtom.java2
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hslf/record/TextRulerAtom.java2
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hslf/record/TextSpecInfoAtom.java4
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hslf/record/TxMasterStyleAtom.java2
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFSlideShow.java2
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFSlideShowImpl.java4
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hsmf/datatypes/PropertiesChunk.java2
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hwmf/usermodel/HwmfEmbeddedIterator.java2
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hwpf/dev/HWPFLister.java2
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hwpf/usermodel/Picture.java5
-rw-r--r--poi-scratchpad/src/test/java/org/apache/poi/hdgf/dev/TestVSDDumper.java2
-rw-r--r--poi-scratchpad/src/test/java/org/apache/poi/hemf/usermodel/TestHemfPicture.java2
-rw-r--r--poi-scratchpad/src/test/java/org/apache/poi/hmef/TestHMEFMessage.java4
-rw-r--r--poi-scratchpad/src/test/java/org/apache/poi/hmef/dev/TestHMEFDumper.java2
-rw-r--r--poi-scratchpad/src/test/java/org/apache/poi/hmef/extractor/TestHMEFContentsExtractor.java2
-rw-r--r--poi-scratchpad/src/test/java/org/apache/poi/hslf/HSLFTestDataSamples.java4
-rw-r--r--poi-scratchpad/src/test/java/org/apache/poi/hslf/TestReWrite.java6
-rw-r--r--poi-scratchpad/src/test/java/org/apache/poi/hslf/TestReWriteSanity.java6
-rw-r--r--poi-scratchpad/src/test/java/org/apache/poi/hslf/dev/BaseTestPPTIterating.java2
-rw-r--r--poi-scratchpad/src/test/java/org/apache/poi/hslf/dev/TestSLWTListing.java2
-rw-r--r--poi-scratchpad/src/test/java/org/apache/poi/hslf/model/TestMovieShape.java2
-rw-r--r--poi-scratchpad/src/test/java/org/apache/poi/hslf/model/TestOleEmbedding.java2
-rw-r--r--poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestAnimationInfoAtom.java4
-rw-r--r--poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestCString.java6
-rw-r--r--poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestColorSchemeAtom.java2
-rw-r--r--poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestComment2000.java6
-rw-r--r--poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestComment2000Atom.java6
-rw-r--r--poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestCurrentUserAtom.java2
-rw-r--r--poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestDocumentAtom.java2
-rw-r--r--poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestDocumentEncryption.java8
-rw-r--r--poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExControl.java4
-rw-r--r--poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExHyperlink.java2
-rw-r--r--poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExHyperlinkAtom.java6
-rw-r--r--poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExMediaAtom.java4
-rw-r--r--poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExObjListAtom.java6
-rw-r--r--poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExOleObjAtom.java4
-rw-r--r--poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExOleObjStg.java4
-rw-r--r--poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExVideoContainer.java4
-rw-r--r--poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestFontCollection.java2
-rw-r--r--poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestHeadersFootersAtom.java4
-rw-r--r--poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestHeadersFootersContainer.java8
-rw-r--r--poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestInteractiveInfo.java4
-rw-r--r--poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestInteractiveInfoAtom.java6
-rw-r--r--poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestNotesAtom.java2
-rw-r--r--poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestSlideAtom.java2
-rw-r--r--poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestSlidePersistAtom.java2
-rw-r--r--poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestStyleTextPropAtom.java10
-rw-r--r--poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestTextBytesAtom.java4
-rw-r--r--poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestTextCharsAtom.java6
-rw-r--r--poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestTextHeaderAtom.java2
-rw-r--r--poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestTextRulerAtom.java4
-rw-r--r--poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestTextSpecInfoAtom.java4
-rw-r--r--poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestTxInteractiveInfoAtom.java6
-rw-r--r--poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestUserEditAtom.java2
-rw-r--r--poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestHSLFSlideShow.java2
-rw-r--r--poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestPictures.java4
-rw-r--r--poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestRichTextRun.java4
-rw-r--r--poi-scratchpad/src/test/java/org/apache/poi/hsmf/TestExtractEmbeddedMSG.java4
-rw-r--r--poi-scratchpad/src/test/java/org/apache/poi/hsmf/TestFileWithAttachmentsRead.java2
-rw-r--r--poi-scratchpad/src/test/java/org/apache/poi/hsmf/TestFixedSizedProperties.java4
-rw-r--r--poi-scratchpad/src/test/java/org/apache/poi/hwpf/HWPFTestCase.java2
-rw-r--r--poi-scratchpad/src/test/java/org/apache/poi/hwpf/HWPFTestDataSamples.java2
-rw-r--r--poi-scratchpad/src/test/java/org/apache/poi/hwpf/dev/TestHWPFLister.java2
-rw-r--r--poi-scratchpad/src/test/java/org/apache/poi/hwpf/usermodel/TestHWPFWrite.java2
92 files changed, 161 insertions, 155 deletions
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/extractor/ole2/OLE2ScratchpadExtractorFactory.java b/poi-scratchpad/src/main/java/org/apache/poi/extractor/ole2/OLE2ScratchpadExtractorFactory.java
index 2485589e31..64c2c6fce0 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/extractor/ole2/OLE2ScratchpadExtractorFactory.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/extractor/ole2/OLE2ScratchpadExtractorFactory.java
@@ -185,7 +185,12 @@ public class OLE2ScratchpadExtractorFactory implements ExtractorProvider {
for (AttachmentChunks attachment : msg.getAttachmentFiles()) {
if (attachment.getAttachData() != null) {
byte[] data = attachment.getAttachData().getValue();
- nonPOIFS.add( new UnsynchronizedByteArrayInputStream(data) );
+ try {
+ nonPOIFS.add(UnsynchronizedByteArrayInputStream.builder().setByteArray(data).get() );
+ } catch (IOException e) {
+ // is actually impossible with ByteArray, but still declared in the interface
+ throw new IllegalStateException(e);
+ }
} else if (attachment.getAttachmentDirectory() != null) {
dirs.add(attachment.getAttachmentDirectory().getDirectory());
}
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hdgf/HDGFLZW.java b/poi-scratchpad/src/main/java/org/apache/poi/hdgf/HDGFLZW.java
index 5e70f033a2..1a961963fb 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hdgf/HDGFLZW.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hdgf/HDGFLZW.java
@@ -53,7 +53,7 @@ public class HDGFLZW extends LZWDecompresser {
* @throws IOException when the InputStream can't be read
*/
public byte[] compress(InputStream src) throws IOException {
- UnsynchronizedByteArrayOutputStream res = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream res = UnsynchronizedByteArrayOutputStream.builder().get();
compress(src,res);
return res.toByteArray();
}
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hdgf/streams/CompressedStreamStore.java b/poi-scratchpad/src/main/java/org/apache/poi/hdgf/streams/CompressedStreamStore.java
index 0009a3d511..d4ca5c8bc9 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hdgf/streams/CompressedStreamStore.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hdgf/streams/CompressedStreamStore.java
@@ -92,7 +92,7 @@ public final class CompressedStreamStore extends StreamStore {
* Decompresses the given data, returning it as header + contents
*/
public static byte[][] decompress(byte[] data, int offset, int length) throws IOException {
- try (UnsynchronizedByteArrayInputStream bais = new UnsynchronizedByteArrayInputStream(data, offset, length)) {
+ try (UnsynchronizedByteArrayInputStream bais = UnsynchronizedByteArrayInputStream.builder().setByteArray(data).setOffset(offset).setLength(length).get()) {
// Decompress
HDGFLZW lzw = new HDGFLZW();
byte[] decompressed = lzw.decompress(bais);
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hemf/draw/HemfImageRenderer.java b/poi-scratchpad/src/main/java/org/apache/poi/hemf/draw/HemfImageRenderer.java
index 221c9d5a5a..27efbe18a9 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hemf/draw/HemfImageRenderer.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hemf/draw/HemfImageRenderer.java
@@ -65,7 +65,7 @@ public class HemfImageRenderer implements ImageRenderer, EmbeddedExtractor {
if (!PictureData.PictureType.EMF.contentType.equals(contentType)) {
throw new IOException("Invalid picture type");
}
- image = new HemfPicture(new UnsynchronizedByteArrayInputStream(data));
+ image = new HemfPicture(UnsynchronizedByteArrayInputStream.builder().setByteArray(data).get());
}
@Override
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hemf/record/emf/HemfFill.java b/poi-scratchpad/src/main/java/org/apache/poi/hemf/record/emf/HemfFill.java
index f1b668e3f0..4930959fde 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hemf/record/emf/HemfFill.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hemf/record/emf/HemfFill.java
@@ -792,7 +792,7 @@ public final class HemfFill {
return (long)undefinedSpace1 + bitmap.init(leis, dibSize);
}
- final UnsynchronizedByteArrayOutputStream bos = new UnsynchronizedByteArrayOutputStream(cbBmi+cbBits);
+ final UnsynchronizedByteArrayOutputStream bos = UnsynchronizedByteArrayOutputStream.builder().setBufferSize(cbBmi+cbBits).get();
final long cbBmiSrcAct = IOUtils.copy(leis, bos, cbBmi);
assert (cbBmiSrcAct == cbBmi);
leis.skipFully(undefinedSpace2);
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hemf/record/emfplus/HemfPlusBrush.java b/poi-scratchpad/src/main/java/org/apache/poi/hemf/record/emfplus/HemfPlusBrush.java
index 09c17d054b..6c34385070 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hemf/record/emfplus/HemfPlusBrush.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hemf/record/emfplus/HemfPlusBrush.java
@@ -396,7 +396,7 @@ public class HemfPlusBrush {
public EmfPlusBrushData getBrushData(List<? extends EmfPlusObjectData> continuedObjectData) {
EmfPlusBrushData brushData = brushType.constructor.get();
byte[] buf = getRawData(continuedObjectData);
- try (UnsynchronizedByteArrayInputStream bis = new UnsynchronizedByteArrayInputStream(buf)){
+ try (UnsynchronizedByteArrayInputStream bis = UnsynchronizedByteArrayInputStream.builder().setByteArray(buf).get()){
brushData.init(new LittleEndianInputStream(bis), buf.length);
} catch (IOException e) {
throw new IllegalStateException(e);
@@ -410,7 +410,7 @@ public class HemfPlusBrush {
* @throws IllegalStateException if the data cannot be processed
*/
public byte[] getRawData(List<? extends EmfPlusObjectData> continuedObjectData) {
- try (UnsynchronizedByteArrayOutputStream bos = new UnsynchronizedByteArrayOutputStream()) {
+ try (UnsynchronizedByteArrayOutputStream bos = UnsynchronizedByteArrayOutputStream.builder().get()) {
bos.write(getBrushBytes());
if (continuedObjectData != null) {
for (EmfPlusObjectData od : continuedObjectData) {
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hemf/record/emfplus/HemfPlusImage.java b/poi-scratchpad/src/main/java/org/apache/poi/hemf/record/emfplus/HemfPlusImage.java
index 6afb53cdd3..76436f697d 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hemf/record/emfplus/HemfPlusImage.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hemf/record/emfplus/HemfPlusImage.java
@@ -419,13 +419,13 @@ public class HemfPlusImage {
if (getBitmapType() == EmfPlusBitmapDataType.PIXEL) {
return new Rectangle2D.Double(0, 0, bitmapWidth, bitmapHeight);
} else {
- try(UnsynchronizedByteArrayInputStream is = new UnsynchronizedByteArrayInputStream(getRawData(continuedObjectData))) {
+ try(UnsynchronizedByteArrayInputStream is = UnsynchronizedByteArrayInputStream.builder().setByteArray(getRawData(continuedObjectData)).get()) {
BufferedImage bi = ImageIO.read(is);
return new Rectangle2D.Double(bi.getMinX(), bi.getMinY(), bi.getWidth(), bi.getHeight());
}
}
case METAFILE:
- try(UnsynchronizedByteArrayInputStream bis = new UnsynchronizedByteArrayInputStream(getRawData(continuedObjectData))) {
+ try(UnsynchronizedByteArrayInputStream bis = UnsynchronizedByteArrayInputStream.builder().setByteArray(getRawData(continuedObjectData)).get()) {
switch (getMetafileType()) {
case Wmf:
case WmfPlaceable:
@@ -453,7 +453,7 @@ public class HemfPlusImage {
* @throws IllegalStateException if the data cannot be read
*/
public byte[] getRawData(List<? extends EmfPlusObjectData> continuedObjectData) {
- try (UnsynchronizedByteArrayOutputStream bos = new UnsynchronizedByteArrayOutputStream()) {
+ try (UnsynchronizedByteArrayOutputStream bos = UnsynchronizedByteArrayOutputStream.builder().get()) {
bos.write(getImageData());
if (continuedObjectData != null) {
for (EmfPlusObjectData od : continuedObjectData) {
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hemf/usermodel/HemfEmbeddedIterator.java b/poi-scratchpad/src/main/java/org/apache/poi/hemf/usermodel/HemfEmbeddedIterator.java
index d6d2b536f4..c0c2763ac8 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hemf/usermodel/HemfEmbeddedIterator.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hemf/usermodel/HemfEmbeddedIterator.java
@@ -293,7 +293,7 @@ public class HemfEmbeddedIterator implements Iterator<HwmfEmbedded> {
private void compressGDIBitmap(EmfPlusImage img, HwmfEmbedded emb, HwmfEmbeddedType et) {
BufferedImage bi = img.readGDIImage(emb.getRawData());
try {
- UnsynchronizedByteArrayOutputStream bos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream bos = UnsynchronizedByteArrayOutputStream.builder().get();
// use HwmfEmbeddedType literal for conversion
ImageIO.write(bi, et.toString(), bos);
emb.setData(bos.toByteArray());
@@ -318,7 +318,7 @@ public class HemfEmbeddedIterator implements Iterator<HwmfEmbedded> {
: epo.getTotalObjectSize();
IOUtils.safelyAllocateCheck(totalSize, MAX_RECORD_LENGTH);
- try (UnsynchronizedByteArrayOutputStream bos = new UnsynchronizedByteArrayOutputStream(totalSize)) {
+ try (UnsynchronizedByteArrayOutputStream bos = UnsynchronizedByteArrayOutputStream.builder().setBufferSize(totalSize).get()) {
boolean hasNext = false;
do {
EmfPlusImage img = epo.getObjectData();
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hmef/attribute/MAPIAttribute.java b/poi-scratchpad/src/main/java/org/apache/poi/hmef/attribute/MAPIAttribute.java
index f851526ea3..de08c4fc49 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hmef/attribute/MAPIAttribute.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hmef/attribute/MAPIAttribute.java
@@ -116,7 +116,7 @@ public class MAPIAttribute {
"instead received a " + parent.getProperty() + " one"
);
}
- try(UnsynchronizedByteArrayInputStream inp = new UnsynchronizedByteArrayInputStream(parent.getData())) {
+ try(UnsynchronizedByteArrayInputStream inp = UnsynchronizedByteArrayInputStream.builder().setByteArray(parent.getData()).get()) {
// First up, get the number of attributes
int count = LittleEndian.readInt(inp);
List<MAPIAttribute> attrs = new ArrayList<>();
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hmef/attribute/MAPIRtfAttribute.java b/poi-scratchpad/src/main/java/org/apache/poi/hmef/attribute/MAPIRtfAttribute.java
index f8b2d19522..6683beb878 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hmef/attribute/MAPIRtfAttribute.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hmef/attribute/MAPIRtfAttribute.java
@@ -46,7 +46,7 @@ public final class MAPIRtfAttribute extends MAPIAttribute {
// Decompress it, removing any trailing padding as needed
CompressedRTF rtf = new CompressedRTF();
byte[] tmp;
- try (InputStream is = new UnsynchronizedByteArrayInputStream(data)) {
+ try (InputStream is = UnsynchronizedByteArrayInputStream.builder().setByteArray(data).get()) {
tmp = rtf.decompress(is);
}
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hpbf/model/HPBFPart.java b/poi-scratchpad/src/main/java/org/apache/poi/hpbf/model/HPBFPart.java
index f727360b34..a723fc2cc1 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hpbf/model/HPBFPart.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hpbf/model/HPBFPart.java
@@ -83,7 +83,7 @@ public abstract class HPBFPart {
generateData();
// Write out
- try (UnsynchronizedByteArrayInputStream bais = new UnsynchronizedByteArrayInputStream(data)) {
+ try (UnsynchronizedByteArrayInputStream bais = UnsynchronizedByteArrayInputStream.builder().setByteArray(data).get()) {
dir.createDocument(path[path.length-1], bais);
}
}
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hslf/blip/Bitmap.java b/poi-scratchpad/src/main/java/org/apache/poi/hslf/blip/Bitmap.java
index 9d6a3ba773..a1b90a8e7e 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hslf/blip/Bitmap.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hslf/blip/Bitmap.java
@@ -91,7 +91,7 @@ public abstract class Bitmap extends HSLFPictureData {
@Override
public Dimension getImageDimension() {
- try (InputStream is = new UnsynchronizedByteArrayInputStream(getData())){
+ try (InputStream is = UnsynchronizedByteArrayInputStream.builder().setByteArray(getData()).get()){
BufferedImage bi = ImageIO.read(is);
return new Dimension(
(int)Units.pixelToPoints(bi.getWidth()),
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hslf/blip/EMF.java b/poi-scratchpad/src/main/java/org/apache/poi/hslf/blip/EMF.java
index fd1df89ca6..d8d9231f49 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hslf/blip/EMF.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hslf/blip/EMF.java
@@ -69,9 +69,9 @@ public final class EMF extends Metafile {
header.read(rawdata, CHECKSUM_SIZE);
try (
- InputStream is = new UnsynchronizedByteArrayInputStream(rawdata);
+ InputStream is = UnsynchronizedByteArrayInputStream.builder().setByteArray(rawdata).get();
InflaterInputStream inflater = new InflaterInputStream(is);
- UnsynchronizedByteArrayOutputStream out = new UnsynchronizedByteArrayOutputStream()
+ UnsynchronizedByteArrayOutputStream out = UnsynchronizedByteArrayOutputStream.builder().get()
) {
long len = IOUtils.skipFully(is,header.getSize() + (long)CHECKSUM_SIZE);
assert(len == header.getSize() + CHECKSUM_SIZE);
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hslf/blip/Metafile.java b/poi-scratchpad/src/main/java/org/apache/poi/hslf/blip/Metafile.java
index acb3e849a2..e449f13506 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hslf/blip/Metafile.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hslf/blip/Metafile.java
@@ -91,7 +91,7 @@ public abstract class Metafile extends HSLFPictureData {
public void read(byte[] data, int offset) {
try (
LittleEndianInputStream leis = new LittleEndianInputStream(
- new UnsynchronizedByteArrayInputStream(data, offset, RECORD_LENGTH))
+ UnsynchronizedByteArrayInputStream.builder().setByteArray(data).setOffset(offset).setLength(RECORD_LENGTH).get())
) {
wmfsize = leis.readInt();
@@ -204,7 +204,7 @@ public abstract class Metafile extends HSLFPictureData {
}
protected static byte[] compress(byte[] bytes, int offset, int length) {
- UnsynchronizedByteArrayOutputStream out = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream out = UnsynchronizedByteArrayOutputStream.builder().get();
try (DeflaterOutputStream deflater = new DeflaterOutputStream(out)) {
deflater.write(bytes, offset, length);
} catch (IOException ignored) {
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hslf/blip/PICT.java b/poi-scratchpad/src/main/java/org/apache/poi/hslf/blip/PICT.java
index 3e5042af46..fdc23e9e3e 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hslf/blip/PICT.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hslf/blip/PICT.java
@@ -72,7 +72,7 @@ public final class PICT extends Metafile {
@Override
public byte[] getData(){
byte[] rawdata = getRawData();
- try (UnsynchronizedByteArrayOutputStream out = new UnsynchronizedByteArrayOutputStream()) {
+ try (UnsynchronizedByteArrayOutputStream out = UnsynchronizedByteArrayOutputStream.builder().get()) {
byte[] macheader = new byte[512];
out.write(macheader);
int pos = CHECKSUM_SIZE*getUIDInstanceCount();
@@ -88,13 +88,13 @@ public final class PICT extends Metafile {
Header header = new Header();
header.read(data, pos);
long bs_exp = (long)pos + header.getSize();
- try (InputStream bis = new UnsynchronizedByteArrayInputStream(data)) {
+ try (InputStream bis = UnsynchronizedByteArrayInputStream.builder().setByteArray(data).get()) {
long bs_act = IOUtils.skipFully(bis, bs_exp);
if (bs_exp != bs_act) {
throw new EOFException();
}
byte[] chunk = new byte[4096];
- try (UnsynchronizedByteArrayOutputStream out = new UnsynchronizedByteArrayOutputStream(header.getWmfSize())) {
+ try (UnsynchronizedByteArrayOutputStream out = UnsynchronizedByteArrayOutputStream.builder().setBufferSize(header.getWmfSize()).get()) {
try (InflaterInputStream inflater = new InflaterInputStream(bis)) {
int count;
while ((count = inflater.read(chunk)) >= 0) {
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hslf/blip/WMF.java b/poi-scratchpad/src/main/java/org/apache/poi/hslf/blip/WMF.java
index 73da07c9b4..16e7d5f294 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hslf/blip/WMF.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hslf/blip/WMF.java
@@ -65,7 +65,7 @@ public final class WMF extends Metafile {
@Override
public byte[] getData(){
byte[] rawdata = getRawData();
- try (InputStream is = new UnsynchronizedByteArrayInputStream(rawdata)) {
+ try (InputStream is = UnsynchronizedByteArrayInputStream.builder().setByteArray(rawdata).get()) {
Header header = new Header();
@@ -75,7 +75,7 @@ public final class WMF extends Metafile {
assert(skipped == skipLen);
ImageHeaderWMF aldus = new ImageHeaderWMF(header.getBounds());
- UnsynchronizedByteArrayOutputStream out = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream out = UnsynchronizedByteArrayOutputStream.builder().get();
aldus.write(out);
try (InflaterInputStream inflater = new InflaterInputStream( is )) {
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hslf/dev/PPTXMLDump.java b/poi-scratchpad/src/main/java/org/apache/poi/hslf/dev/PPTXMLDump.java
index 3dca0340d1..7940dae77d 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hslf/dev/PPTXMLDump.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hslf/dev/PPTXMLDump.java
@@ -65,7 +65,7 @@ public final class PPTXMLDump {
return null;
}
try (InputStream is = dn.createDocumentInputStream(entry);
- UnsynchronizedByteArrayOutputStream bos = new UnsynchronizedByteArrayOutputStream()) {
+ UnsynchronizedByteArrayOutputStream bos = UnsynchronizedByteArrayOutputStream.builder().get()) {
IOUtils.copy(is, bos);
return bos.toByteArray();
}
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hslf/dev/SlideIdListing.java b/poi-scratchpad/src/main/java/org/apache/poi/hslf/dev/SlideIdListing.java
index b335752e9c..6f8c596450 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hslf/dev/SlideIdListing.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hslf/dev/SlideIdListing.java
@@ -147,7 +147,7 @@ public final class SlideIdListing {
}
// Increase the position by the on disk size
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get();
r.writeOut(baos);
pos += baos.size();
}
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hslf/dev/SlideShowRecordDumper.java b/poi-scratchpad/src/main/java/org/apache/poi/hslf/dev/SlideShowRecordDumper.java
index f1898ccd88..005da13472 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hslf/dev/SlideShowRecordDumper.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hslf/dev/SlideShowRecordDumper.java
@@ -146,7 +146,7 @@ public final class SlideShowRecordDumper {
public int getDiskLen(org.apache.poi.hslf.record.Record r) throws IOException {
int diskLen = 0;
if (r != null) {
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get();
r.writeOut(baos);
diskLen = baos.size();
}
@@ -158,7 +158,7 @@ public final class SlideShowRecordDumper {
return "<<null>>";
}
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get();
r.writeOut(baos);
byte[] b = baos.toByteArray();
return HexDump.dump(b, 0, 0);
@@ -258,7 +258,7 @@ public final class SlideShowRecordDumper {
if (optEscher && cname.equals("PPDrawing")) {
DefaultEscherRecordFactory factory = new HSLFEscherRecordFactory();
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get();
r.writeOut(baos);
byte[] b = baos.toByteArray();
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hslf/dev/UserEditAndPersistListing.java b/poi-scratchpad/src/main/java/org/apache/poi/hslf/dev/UserEditAndPersistListing.java
index 5803b42588..f0aeaff126 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hslf/dev/UserEditAndPersistListing.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hslf/dev/UserEditAndPersistListing.java
@@ -79,7 +79,7 @@ public final class UserEditAndPersistListing {
}
// Increase the position by the on disk size
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get();
r.writeOut(baos);
pos += baos.size();
}
@@ -99,7 +99,7 @@ public final class UserEditAndPersistListing {
}
// Increase the position by the on disk size
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get();
r.writeOut(baos);
pos += baos.size();
}
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hslf/model/textproperties/TextPropCollection.java b/poi-scratchpad/src/main/java/org/apache/poi/hslf/model/textproperties/TextPropCollection.java
index 814c82e788..fa9618483f 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hslf/model/textproperties/TextPropCollection.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hslf/model/textproperties/TextPropCollection.java
@@ -379,7 +379,7 @@ public class TextPropCollection implements GenericRecord, Duplicatable {
out.append(" bytes that would be written: \n");
try {
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get();
writeOut(baos);
byte[] b = baos.toByteArray();
out.append(HexDump.dump(b, 0, 0));
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ColorSchemeAtom.java b/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ColorSchemeAtom.java
index 6664b76676..2b4561c2f5 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ColorSchemeAtom.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ColorSchemeAtom.java
@@ -154,7 +154,7 @@ public final class ColorSchemeAtom extends RecordAtom {
byte[] ret = new byte[3];
// Serialise to bytes, then grab the right ones out
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get();
try {
writeLittleEndian(rgb,baos);
} catch(IOException ie) {
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/CurrentUserAtom.java b/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/CurrentUserAtom.java
index 9d54004166..70e422b838 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/CurrentUserAtom.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/CurrentUserAtom.java
@@ -264,7 +264,7 @@ public class CurrentUserAtom {
*/
public void writeToFS(POIFSFileSystem fs) throws IOException {
// Grab contents
- try (UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream()) {
+ try (UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get()) {
writeOut(baos);
try (InputStream is = baos.toInputStream()) {
// Write out
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/EscherTextboxWrapper.java b/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/EscherTextboxWrapper.java
index 4164158e5f..f2f909d999 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/EscherTextboxWrapper.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/EscherTextboxWrapper.java
@@ -89,7 +89,7 @@ public final class EscherTextboxWrapper extends RecordContainer {
// Write out our children, and stuff them into the Escher layer
// Grab the children's data
- try (UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream()) {
+ try (UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get()) {
for (org.apache.poi.hslf.record.Record r : _children) {
r.writeOut(baos);
}
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ExOleObjStg.java b/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ExOleObjStg.java
index d4366fa436..2849601612 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ExOleObjStg.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ExOleObjStg.java
@@ -124,7 +124,7 @@ public class ExOleObjStg extends PositionDependentRecordAtom implements PersistR
* @param data the embedded data.
*/
public void setData(byte[] data) throws IOException {
- try (UnsynchronizedByteArrayOutputStream out = new UnsynchronizedByteArrayOutputStream();
+ try (UnsynchronizedByteArrayOutputStream out = UnsynchronizedByteArrayOutputStream.builder().get();
DeflaterOutputStream def = new DeflaterOutputStream(out)) {
//first four bytes is the length of the raw data
byte[] b = new byte[4];
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/HSLFEscherClientDataRecord.java b/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/HSLFEscherClientDataRecord.java
index 14751254d6..9ee2d60c83 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/HSLFEscherClientDataRecord.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/HSLFEscherClientDataRecord.java
@@ -93,7 +93,7 @@ public class HSLFEscherClientDataRecord extends EscherClientDataRecord {
@Override
public byte[] getRemainingData() {
- try (UnsynchronizedByteArrayOutputStream bos = new UnsynchronizedByteArrayOutputStream()) {
+ try (UnsynchronizedByteArrayOutputStream bos = UnsynchronizedByteArrayOutputStream.builder().get()) {
for (org.apache.poi.hslf.record.Record r : _childRecords) {
r.writeOut(bos);
}
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/PPDrawingGroup.java b/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/PPDrawingGroup.java
index 957edcb945..08ab371e63 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/PPDrawingGroup.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/PPDrawingGroup.java
@@ -82,8 +82,8 @@ public final class PPDrawingGroup extends RecordAtom {
public void writeOut(OutputStream out) throws IOException {
byte[] bstorehead = new byte[8];
byte[] recordBytes = new byte[36 + 8];
- try (UnsynchronizedByteArrayOutputStream bout = new UnsynchronizedByteArrayOutputStream();
- UnsynchronizedByteArrayOutputStream recordBuf = new UnsynchronizedByteArrayOutputStream()) {
+ try (UnsynchronizedByteArrayOutputStream bout = UnsynchronizedByteArrayOutputStream.builder().get();
+ UnsynchronizedByteArrayOutputStream recordBuf = UnsynchronizedByteArrayOutputStream.builder().get()) {
for (EscherRecord r : dggContainer) {
if (r.getRecordId() == EscherContainerRecord.BSTORE_CONTAINER) {
EscherContainerRecord bstore = (EscherContainerRecord) r;
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/RecordContainer.java b/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/RecordContainer.java
index abd3a22ced..f970b8d5f1 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/RecordContainer.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/RecordContainer.java
@@ -227,7 +227,7 @@ public abstract class RecordContainer extends Record
*/
public void writeOut(byte headerA, byte headerB, long type, Record[] children, OutputStream out) throws IOException {
// Create a UnsynchronizedByteArrayOutputStream to hold everything in
- try (UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream()) {
+ try (UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get()) {
// Write out our header, less the size
baos.write(new byte[]{headerA, headerB});
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/StyleTextPropAtom.java b/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/StyleTextPropAtom.java
index 62773615e0..eb683b42aa 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/StyleTextPropAtom.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/StyleTextPropAtom.java
@@ -308,7 +308,7 @@ public final class StyleTextPropAtom extends RecordAtom {
private void updateRawContents() throws IOException {
if (initialised) {
// Only update the style bytes, if the styles have been potentially changed
- try (UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream()) {
+ try (UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get()) {
// First up, we need to serialise the paragraph properties
for (TextPropCollection tpc : paragraphStyles) {
tpc.writeOut(baos);
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/TextRulerAtom.java b/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/TextRulerAtom.java
index d9e18a30d0..df9db94f86 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/TextRulerAtom.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/TextRulerAtom.java
@@ -117,7 +117,7 @@ public final class TextRulerAtom extends RecordAtom {
*/
@Override
public void writeOut(final OutputStream out) throws IOException {
- final UnsynchronizedByteArrayOutputStream bos = new UnsynchronizedByteArrayOutputStream(200);
+ final UnsynchronizedByteArrayOutputStream bos = UnsynchronizedByteArrayOutputStream.builder().setBufferSize(200).get();
final LittleEndianOutputStream lbos = new LittleEndianOutputStream(bos);
int mask = 0;
mask |= writeIf(lbos, numLevels, C_LEVELS);
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/TextSpecInfoAtom.java b/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/TextSpecInfoAtom.java
index aa71d41540..01f3dc9d8e 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/TextSpecInfoAtom.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/TextSpecInfoAtom.java
@@ -109,7 +109,7 @@ public final class TextSpecInfoAtom extends RecordAtom {
*/
public void reset(int size){
TextSpecInfoRun sir = new TextSpecInfoRun(size);
- UnsynchronizedByteArrayOutputStream bos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream bos = UnsynchronizedByteArrayOutputStream.builder().get();
try {
sir.writeOut(bos);
} catch (IOException e) {
@@ -128,7 +128,7 @@ public final class TextSpecInfoAtom extends RecordAtom {
public void setParentSize(int size) {
assert(size > 0);
- try (UnsynchronizedByteArrayOutputStream bos = new UnsynchronizedByteArrayOutputStream()) {
+ try (UnsynchronizedByteArrayOutputStream bos = UnsynchronizedByteArrayOutputStream.builder().get()) {
TextSpecInfoRun[] runs = getTextSpecInfoRuns();
int remaining = size;
int idx = 0;
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/TxMasterStyleAtom.java b/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/TxMasterStyleAtom.java
index ca94a6acfd..610ad27c39 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/TxMasterStyleAtom.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/TxMasterStyleAtom.java
@@ -187,7 +187,7 @@ public final class TxMasterStyleAtom extends RecordAtom {
int type = getTextType();
try {
- UnsynchronizedByteArrayOutputStream bos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream bos = UnsynchronizedByteArrayOutputStream.builder().get();
LittleEndianOutputStream leos = new LittleEndianOutputStream(bos);
int levels = paragraphStyles.size();
leos.writeShort(levels);
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFSlideShow.java b/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFSlideShow.java
index 1239fe686f..15476e48f3 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFSlideShow.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFSlideShow.java
@@ -1080,7 +1080,7 @@ public final class HSLFSlideShow extends POIDocument implements SlideShow<HSLFSh
ExOleObjStg exOleObjStg = new ExOleObjStg();
try {
Ole10Native.createOleMarkerEntry(poiData);
- UnsynchronizedByteArrayOutputStream bos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream bos = UnsynchronizedByteArrayOutputStream.builder().get();
poiData.writeFilesystem(bos);
exOleObjStg.setData(bos.toByteArray());
} catch (IOException e) {
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFSlideShowImpl.java b/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFSlideShowImpl.java
index 953ef3733a..54edf47faa 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFSlideShowImpl.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFSlideShowImpl.java
@@ -811,7 +811,7 @@ public final class HSLFSlideShowImpl extends POIDocument implements Closeable {
// Write out the Property Streams
writeProperties(outFS, writtenEntries);
- try (UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream()) {
+ try (UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get()) {
// For position dependent records, hold where they were and now are
// As we go along, update, and hand over, to any Position Dependent
@@ -852,7 +852,7 @@ public final class HSLFSlideShowImpl extends POIDocument implements Closeable {
}
private static InputStream encryptOnePicture(HSLFSlideShowEncrypted encryptedSS, HSLFPictureData data) {
- try (UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream()) {
+ try (UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get()) {
data.write(baos);
byte[] pictBytes = baos.toByteArray();
encryptedSS.encryptPicture(pictBytes, 0);
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hsmf/datatypes/PropertiesChunk.java b/poi-scratchpad/src/main/java/org/apache/poi/hsmf/datatypes/PropertiesChunk.java
index cdc146d980..64a3a31c21 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hsmf/datatypes/PropertiesChunk.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hsmf/datatypes/PropertiesChunk.java
@@ -319,7 +319,7 @@ public abstract class PropertiesChunk extends Chunk {
* If an I/O error occurs.
*/
public void writeProperties(DirectoryEntry directory) throws IOException {
- try (UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream()) {
+ try (UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get()) {
List<PropertyValue> values = writeProperties(baos);
// write the header data with the properties declaration
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hwmf/usermodel/HwmfEmbeddedIterator.java b/poi-scratchpad/src/main/java/org/apache/poi/hwmf/usermodel/HwmfEmbeddedIterator.java
index 03dfdec402..cf15734217 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hwmf/usermodel/HwmfEmbeddedIterator.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hwmf/usermodel/HwmfEmbeddedIterator.java
@@ -114,7 +114,7 @@ public class HwmfEmbeddedIterator implements Iterator<HwmfEmbedded> {
final HwmfEmbedded emb = new HwmfEmbedded();
emb.setEmbeddedType(HwmfEmbeddedType.EMF);
- try (UnsynchronizedByteArrayOutputStream bos = new UnsynchronizedByteArrayOutputStream()) {
+ try (UnsynchronizedByteArrayOutputStream bos = UnsynchronizedByteArrayOutputStream.builder().get()) {
WmfEscapeEMF img;
do {
final HwmfEscape esc = (HwmfEscape)current;
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/dev/HWPFLister.java b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/dev/HWPFLister.java
index 52ae97a3ed..214af0afa1 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/dev/HWPFLister.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/dev/HWPFLister.java
@@ -256,7 +256,7 @@ public final class HWPFLister {
private static HWPFDocumentCore writeOutAndReadBack(
HWPFDocumentCore original ) {
- try (UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream()) {
+ try (UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get()) {
original.write( baos );
try (InputStream is = baos.toInputStream()) {
return loadDoc(is);
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/usermodel/Picture.java b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/usermodel/Picture.java
index 05b22ccd00..7ba7892b28 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/usermodel/Picture.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/usermodel/Picture.java
@@ -140,9 +140,10 @@ public final class Picture {
*/
if ( matchSignature( rawContent, COMPRESSED1, 32 )
|| matchSignature( rawContent, COMPRESSED2, 32 ) ) {
- try (UnsynchronizedByteArrayInputStream bis = new UnsynchronizedByteArrayInputStream( rawContent, 33, rawContent.length - 33 );
+ try (UnsynchronizedByteArrayInputStream bis = UnsynchronizedByteArrayInputStream.builder().setByteArray(rawContent).
+ setOffset(33).setLength(rawContent.length - 33).get();
InflaterInputStream in = new InflaterInputStream(bis);
- UnsynchronizedByteArrayOutputStream out = new UnsynchronizedByteArrayOutputStream()) {
+ UnsynchronizedByteArrayOutputStream out = UnsynchronizedByteArrayOutputStream.builder().get()) {
IOUtils.copy(in, out);
content = out.toByteArray();
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hdgf/dev/TestVSDDumper.java b/poi-scratchpad/src/test/java/org/apache/poi/hdgf/dev/TestVSDDumper.java
index 6a1a830a0b..a192125081 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hdgf/dev/TestVSDDumper.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hdgf/dev/TestVSDDumper.java
@@ -33,7 +33,7 @@ public class TestVSDDumper {
@Test
void main() {
PrintStream oldStdOut = System.out;
- System.setOut(new NullPrintStream());
+ System.setOut(NullPrintStream.INSTANCE);
try {
File file = POIDataSamples.getDiagramInstance().getFile("Test_Visio-Some_Random_Text.vsd");
String[] args = { file.getAbsolutePath() };
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hemf/usermodel/TestHemfPicture.java b/poi-scratchpad/src/test/java/org/apache/poi/hemf/usermodel/TestHemfPicture.java
index 1fbc303d78..22740b0cf6 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hemf/usermodel/TestHemfPicture.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hemf/usermodel/TestHemfPicture.java
@@ -221,7 +221,7 @@ public class TestHemfPicture {
@Test
void testInfiniteLoopOnByteArray() throws Exception {
try (InputStream is = ss_samples.openResourceAsStream("61294.emf")) {
- UnsynchronizedByteArrayOutputStream bos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream bos = UnsynchronizedByteArrayOutputStream.builder().get();
IOUtils.copy(is, bos);
HemfPicture pic = new HemfPicture(bos.toInputStream());
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hmef/TestHMEFMessage.java b/poi-scratchpad/src/test/java/org/apache/poi/hmef/TestHMEFMessage.java
index 5717e5157d..5a12ac6426 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hmef/TestHMEFMessage.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hmef/TestHMEFMessage.java
@@ -169,7 +169,7 @@ public final class TestHMEFMessage {
@Test
void testNoData() throws Exception {
- UnsynchronizedByteArrayOutputStream out = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream out = UnsynchronizedByteArrayOutputStream.builder().get();
// Header
LittleEndian.putInt(HMEFMessage.HEADER_SIGNATURE, out);
@@ -184,7 +184,7 @@ public final class TestHMEFMessage {
@Test
void testInvalidLevel() throws Exception {
- UnsynchronizedByteArrayOutputStream out = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream out = UnsynchronizedByteArrayOutputStream.builder().get();
// Header
LittleEndian.putInt(HMEFMessage.HEADER_SIGNATURE, out);
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hmef/dev/TestHMEFDumper.java b/poi-scratchpad/src/test/java/org/apache/poi/hmef/dev/TestHMEFDumper.java
index 49ef65cb83..df27e801a6 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hmef/dev/TestHMEFDumper.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hmef/dev/TestHMEFDumper.java
@@ -52,7 +52,7 @@ public class TestHMEFDumper {
private static void doMain(String... args) throws Exception {
PrintStream ps = System.out;
try {
- System.setOut(new NullPrintStream());
+ System.setOut(NullPrintStream.INSTANCE);
HMEFDumper.main(args);
} finally {
System.setOut(ps);
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hmef/extractor/TestHMEFContentsExtractor.java b/poi-scratchpad/src/test/java/org/apache/poi/hmef/extractor/TestHMEFContentsExtractor.java
index 81912bbba5..9f41088668 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hmef/extractor/TestHMEFContentsExtractor.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hmef/extractor/TestHMEFContentsExtractor.java
@@ -62,7 +62,7 @@ public class TestHMEFContentsExtractor {
POIDataSamples samples = POIDataSamples.getHMEFInstance();
File winmailTNEFFile = samples.getFile("quick-winmail.dat");
HMEFContentsExtractor extractor = new HMEFContentsExtractor(winmailTNEFFile);
- try (UnsynchronizedByteArrayOutputStream out = new UnsynchronizedByteArrayOutputStream()) {
+ try (UnsynchronizedByteArrayOutputStream out = UnsynchronizedByteArrayOutputStream.builder().get()) {
extractor.extractMessageBody(out);
assertTrue(out.size() > 0);
byte[] expectedMagic = new byte[]{'{', '\\', 'r', 't', 'f'};
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/HSLFTestDataSamples.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/HSLFTestDataSamples.java
index 881d543b0d..39d5a32482 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/HSLFTestDataSamples.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/HSLFTestDataSamples.java
@@ -54,7 +54,7 @@ public class HSLFTestDataSamples {
* Useful for verifying that the serialisation round trip
*/
public static HSLFSlideShowImpl writeOutAndReadBack(HSLFSlideShowImpl original) {
- try (UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream()) {
+ try (UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get()) {
original.write(baos);
try (InputStream is = baos.toInputStream()) {
return new HSLFSlideShowImpl(is);
@@ -70,7 +70,7 @@ public class HSLFTestDataSamples {
* Useful for verifying that the serialisation round trip
*/
public static HSLFSlideShow writeOutAndReadBack(HSLFSlideShow original) {
- try (UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream(4096)) {
+ try (UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().setBufferSize(4096).get()) {
original.write(baos);
return new HSLFSlideShow(baos.toInputStream());
} catch (IOException e) {
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/TestReWrite.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/TestReWrite.java
index 687888a69a..48e2666aa1 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/TestReWrite.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/TestReWrite.java
@@ -55,7 +55,7 @@ public final class TestReWrite {
HSLFSlideShowImpl hss = new HSLFSlideShowImpl(pfs)) {
// Write out to a byte array, and to a temp file
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get();
hss.write(baos);
final File file = TempFile.createTempFile("TestHSLF", ".ppt");
@@ -95,7 +95,7 @@ public final class TestReWrite {
assertNotNull(pfsC.getRoot().getEntry("Macros"));
// Write out normally, will loose the macro stream
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get();
hssC.write(baos);
try (POIFSFileSystem pfsNew = new POIFSFileSystem(baos.toInputStream())) {
assertFalse(pfsNew.getRoot().hasEntry("Macros"));
@@ -134,7 +134,7 @@ public final class TestReWrite {
assertDoesNotThrow(ss::getNotes);
// Now write out to a byte array
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get();
hss.write(baos);
// Use POIFS to query that lot
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/TestReWriteSanity.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/TestReWriteSanity.java
index b2991c1533..dbf1866da2 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/TestReWriteSanity.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/TestReWriteSanity.java
@@ -18,7 +18,6 @@
package org.apache.poi.hslf;
-import static org.apache.commons.io.output.NullOutputStream.NULL_OUTPUT_STREAM;
import static org.apache.poi.POITestCase.assertContains;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -26,6 +25,7 @@ import java.util.HashMap;
import java.util.Map;
import org.apache.commons.io.output.CountingOutputStream;
+import org.apache.commons.io.output.NullOutputStream;
import org.apache.commons.io.output.UnsynchronizedByteArrayOutputStream;
import org.apache.poi.POIDataSamples;
import org.apache.poi.hslf.record.CurrentUserAtom;
@@ -64,7 +64,7 @@ public final class TestReWriteSanity {
@Test
void testUserEditAtomsRight() throws Exception {
// Write out to a byte array
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get();
ss.write(baos);
// Create a new one from that
@@ -78,7 +78,7 @@ public final class TestReWriteSanity {
ue.put(0, 0); // Will show 0 if first
int lastUEPos = -1;
- CountingOutputStream cos = new CountingOutputStream(NULL_OUTPUT_STREAM);
+ CountingOutputStream cos = new CountingOutputStream(NullOutputStream.INSTANCE);
for (final Record rec : r) {
int pos = cos.getCount();
if (rec instanceof PersistPtrHolder) {
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/dev/BaseTestPPTIterating.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/dev/BaseTestPPTIterating.java
index 4a0036b010..0ce99759c1 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/dev/BaseTestPPTIterating.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/dev/BaseTestPPTIterating.java
@@ -79,7 +79,7 @@ public abstract class BaseTestPPTIterating {
IOUtils.setByteArrayMaxOverride(5*1024*1024);
// redirect standard out during the test to avoid spamming the console with output
- System.setOut(new NullPrintStream());
+ System.setOut(NullPrintStream.INSTANCE);
}
@AfterEach
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/dev/TestSLWTListing.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/dev/TestSLWTListing.java
index 3ac7adb84d..b828d4745d 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/dev/TestSLWTListing.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/dev/TestSLWTListing.java
@@ -34,7 +34,7 @@ public class TestSLWTListing extends BaseTestPPTIterating {
@BeforeAll
public static void muteStdErr() {
oldStdErr = System.err;
- System.setErr(new NullPrintStream());
+ System.setErr(NullPrintStream.INSTANCE);
}
@AfterAll
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/model/TestMovieShape.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/model/TestMovieShape.java
index 336f6bc4f2..982c870043 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/model/TestMovieShape.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/model/TestMovieShape.java
@@ -57,7 +57,7 @@ public final class TestMovieShape {
shape.setAutoPlay(false);
assertFalse(shape.isAutoPlay());
- UnsynchronizedByteArrayOutputStream out = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream out = UnsynchronizedByteArrayOutputStream.builder().get();
ppt.write(out);
ppt = new HSLFSlideShow(out.toInputStream());
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/model/TestOleEmbedding.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/model/TestOleEmbedding.java
index 1a443d1e18..059fffa299 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/model/TestOleEmbedding.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/model/TestOleEmbedding.java
@@ -145,7 +145,7 @@ public final class TestOleEmbedding {
slide2.addShape(oleShape2);
oleShape2.setAnchor(new Rectangle2D.Double(100,100,100,100));
- UnsynchronizedByteArrayOutputStream bos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream bos = UnsynchronizedByteArrayOutputStream.builder().get();
ppt.write(bos);
ppt = new HSLFSlideShow(bos.toInputStream());
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestAnimationInfoAtom.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestAnimationInfoAtom.java
index dac20b569b..afb18e09fa 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestAnimationInfoAtom.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestAnimationInfoAtom.java
@@ -65,7 +65,7 @@ public final class TestAnimationInfoAtom {
@Test
void testWrite() throws Exception {
AnimationInfoAtom record = new AnimationInfoAtom(data, 0, data.length);
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get();
record.writeOut(baos);
byte[] b = baos.toByteArray();
@@ -81,7 +81,7 @@ public final class TestAnimationInfoAtom {
record.setFlag(AnimationInfoAtom.Play, true);
record.setFlag(AnimationInfoAtom.Synchronous, true);
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get();
record.writeOut(baos);
byte[] b = baos.toByteArray();
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestCString.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestCString.java
index 57af6afcb5..db7e206541 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestCString.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestCString.java
@@ -70,13 +70,13 @@ public final class TestCString {
@Test
void testWrite() throws Exception {
CString ca = new CString(data_a, 0, data_a.length);
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get();
ca.writeOut(baos);
byte[] b = baos.toByteArray();
assertArrayEquals(data_a, b);
CString cb = new CString(data_b, 0, data_a.length);
- UnsynchronizedByteArrayOutputStream baosB = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream baosB = UnsynchronizedByteArrayOutputStream.builder().get();
cb.writeOut(baosB);
b = baosB.toByteArray();
assertArrayEquals(data_b, b);
@@ -99,7 +99,7 @@ public final class TestCString {
}
assertFalse(equals, "Arrays should not be equals");
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get();
ca.writeOut(baos);
byte[] b = baos.toByteArray();
assertArrayEquals(data_b, b);
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestColorSchemeAtom.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestColorSchemeAtom.java
index 03d657a42f..d465118a33 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestColorSchemeAtom.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestColorSchemeAtom.java
@@ -81,7 +81,7 @@ public final class TestColorSchemeAtom {
@Test
void testWrite() throws Exception {
ColorSchemeAtom csa = new ColorSchemeAtom(data_a,0,data_a.length);
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get();
csa.writeOut(baos);
byte[] b = baos.toByteArray();
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestComment2000.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestComment2000.java
index 32213d0e4d..3c94ef7319 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestComment2000.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestComment2000.java
@@ -144,7 +144,7 @@ public final class TestComment2000 {
@Test
void testWrite() throws Exception {
Comment2000 ca = new Comment2000(data_a, 0, data_a.length);
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get();
ca.writeOut(baos);
byte[] b = baos.toByteArray();
assertArrayEquals(data_a, b);
@@ -196,8 +196,8 @@ public final class TestComment2000 {
assertFalse(equals, "Arrays should not be equals");
// Check bytes are now the same
- UnsynchronizedByteArrayOutputStream baosa = new UnsynchronizedByteArrayOutputStream();
- UnsynchronizedByteArrayOutputStream baosn = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream baosa = UnsynchronizedByteArrayOutputStream.builder().get();
+ UnsynchronizedByteArrayOutputStream baosn = UnsynchronizedByteArrayOutputStream.builder().get();
ca.writeOut(baosa);
cn.writeOut(baosn);
byte[] ba = baosa.toByteArray();
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestComment2000Atom.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestComment2000Atom.java
index 734f3b73ad..225d0b5e05 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestComment2000Atom.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestComment2000Atom.java
@@ -106,7 +106,7 @@ public final class TestComment2000Atom {
@Test
void testWrite() throws Exception {
Comment2000Atom ca = new Comment2000Atom(data_a, 0, data_a.length);
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get();
ca.writeOut(baos);
byte[] b = baos.toByteArray();
assertArrayEquals(data_a, b);
@@ -127,7 +127,7 @@ public final class TestComment2000Atom {
a.setDate(date_a);
// Check it's now the same as a
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get();
a.writeOut(baos);
byte[] b = baos.toByteArray();
assertArrayEquals(data_a, b);
@@ -150,7 +150,7 @@ public final class TestComment2000Atom {
ca.setYOffset(0x0E);
// Check bytes are now the same
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get();
ca.writeOut(baos);
byte[] b = baos.toByteArray();
assertArrayEquals(data_b, b);
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestCurrentUserAtom.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestCurrentUserAtom.java
index c8c0cc2eac..a1ee955fd3 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestCurrentUserAtom.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestCurrentUserAtom.java
@@ -89,7 +89,7 @@ public final class TestCurrentUserAtom {
cu.setCurrentEditOffset(0x2942);
// Check it matches
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get();
cu.writeOut(baos);
byte[] out = baos.toByteArray();
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestDocumentAtom.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestDocumentAtom.java
index 9cdf6f62c4..861f43ad85 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestDocumentAtom.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestDocumentAtom.java
@@ -81,7 +81,7 @@ public final class TestDocumentAtom {
@Test
void testWrite() throws Exception {
DocumentAtom da = new DocumentAtom(data_a, 0, data_a.length);
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get();
da.writeOut(baos);
assertArrayEquals(data_a, baos.toByteArray());
}
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestDocumentEncryption.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestDocumentEncryption.java
index 26c00b64a1..926a3e3ede 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestDocumentEncryption.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestDocumentEncryption.java
@@ -87,7 +87,7 @@ public class TestDocumentEncryption {
EncryptionInfo ei = documentEncryptionAtom.getEncryptionInfo();
ei.getHeader().setKeySize(0x78);
- UnsynchronizedByteArrayOutputStream bos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream bos = UnsynchronizedByteArrayOutputStream.builder().get();
hss.write(bos);
try (POIFSFileSystem fs2 = new POIFSFileSystem(bos.toInputStream());
@@ -108,9 +108,9 @@ public class TestDocumentEncryption {
void cryptoAPIEncryption() throws Exception {
/* documents with multiple edits need to be normalized for encryption */
String pptFile = "57272_corrupted_usereditatom.ppt";
- UnsynchronizedByteArrayOutputStream encrypted = new UnsynchronizedByteArrayOutputStream();
- UnsynchronizedByteArrayOutputStream expected = new UnsynchronizedByteArrayOutputStream();
- UnsynchronizedByteArrayOutputStream actual = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream encrypted = UnsynchronizedByteArrayOutputStream.builder().get();
+ UnsynchronizedByteArrayOutputStream expected = UnsynchronizedByteArrayOutputStream.builder().get();
+ UnsynchronizedByteArrayOutputStream actual = UnsynchronizedByteArrayOutputStream.builder().get();
try {
try (POIFSFileSystem fs = new POIFSFileSystem(slTests.getFile(pptFile), true);
HSLFSlideShowImpl hss = new HSLFSlideShowImpl(fs)) {
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExControl.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExControl.java
index fc8c353e33..b8b8a44427 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExControl.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExControl.java
@@ -92,7 +92,7 @@ public final class TestExControl {
@Test
void testWrite() throws Exception {
ExControl record = new ExControl(data, 0, data.length);
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get();
record.writeOut(baos);
assertArrayEquals(data, baos.toByteArray());
}
@@ -115,7 +115,7 @@ public final class TestExControl {
record.setProgId("ShockwaveFlash.ShockwaveFlash.9");
record.setClipboardName("Shockwave Flash Object");
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get();
record.writeOut(baos);
assertArrayEquals(data, baos.toByteArray());
}
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExHyperlink.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExHyperlink.java
index d67a9db105..4eca038dcc 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExHyperlink.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExHyperlink.java
@@ -53,7 +53,7 @@ public final class TestExHyperlink {
assertEquals(expURL, exHyperlink._getDetailsA());
assertEquals(expURL, exHyperlink._getDetailsB());
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get();
exHyperlink.writeOut(baos);
assertArrayEquals(exHyperlinkBytes, baos.toByteArray());
}
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExHyperlinkAtom.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExHyperlinkAtom.java
index f738f44ec8..a9d900f2c9 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExHyperlinkAtom.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExHyperlinkAtom.java
@@ -56,7 +56,7 @@ public class TestExHyperlinkAtom {
@Test
void testWrite() throws Exception {
ExHyperlinkAtom eha = new ExHyperlinkAtom(data_a, 0, data_a.length);
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get();
eha.writeOut(baos);
assertArrayEquals(data_a, baos.toByteArray());
}
@@ -70,7 +70,7 @@ public class TestExHyperlinkAtom {
eha.setNumber(1);
// Check it's now the same as a
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get();
eha.writeOut(baos);
assertArrayEquals(data_a, baos.toByteArray());
}
@@ -84,7 +84,7 @@ public class TestExHyperlinkAtom {
eha.setNumber(4);
// Check bytes are now the same
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get();
eha.writeOut(baos);
assertArrayEquals(data_b, baos.toByteArray());
}
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExMediaAtom.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExMediaAtom.java
index 6d7e08c6a9..ff73e5b846 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExMediaAtom.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExMediaAtom.java
@@ -49,7 +49,7 @@ public final class TestExMediaAtom {
@Test
void testWrite() throws Exception {
ExMediaAtom record = new ExMediaAtom(data, 0, data.length);
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get();
record.writeOut(baos);
byte[] b = baos.toByteArray();
@@ -67,7 +67,7 @@ public final class TestExMediaAtom {
record.setFlag(HeadersFootersAtom.fHasTodayDate, false);
record.setFlag(HeadersFootersAtom.fHasFooter, false);
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get();
record.writeOut(baos);
byte[] b = baos.toByteArray();
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExObjListAtom.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExObjListAtom.java
index d8a5229aba..addc164d88 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExObjListAtom.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExObjListAtom.java
@@ -56,7 +56,7 @@ public class TestExObjListAtom {
@Test
void testWrite() throws Exception {
ExObjListAtom eoa = new ExObjListAtom(data_a, 0, data_a.length);
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get();
eoa.writeOut(baos);
assertArrayEquals(data_a, baos.toByteArray());
}
@@ -70,7 +70,7 @@ public class TestExObjListAtom {
eoa.setObjectIDSeed(1);
// Check it's now the same as a
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get();
eoa.writeOut(baos);
assertArrayEquals(data_a, baos.toByteArray());
}
@@ -84,7 +84,7 @@ public class TestExObjListAtom {
eoa.setObjectIDSeed(4);
// Check bytes are now the same
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get();
eoa.writeOut(baos);
assertArrayEquals(data_b, baos.toByteArray());
}
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExOleObjAtom.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExOleObjAtom.java
index 337f6f5307..a28be1bdef 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExOleObjAtom.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExOleObjAtom.java
@@ -50,7 +50,7 @@ public final class TestExOleObjAtom {
@Test
void testWrite() throws Exception {
ExOleObjAtom record = new ExOleObjAtom(data, 0, data.length);
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get();
record.writeOut(baos);
assertArrayEquals(data, baos.toByteArray());
}
@@ -65,7 +65,7 @@ public final class TestExOleObjAtom {
record.setObjStgDataRef(2);
record.setOptions(1283584);
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get();
record.writeOut(baos);
assertArrayEquals(data, baos.toByteArray());
}
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExOleObjStg.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExOleObjStg.java
index f9d282a095..46d607e729 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExOleObjStg.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExOleObjStg.java
@@ -70,7 +70,7 @@ public final class TestExOleObjStg {
@Test
void testWrite() throws Exception {
ExOleObjStg record = new ExOleObjStg(data, 0, data.length);
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get();
record.writeOut(baos);
byte[] b = baos.toByteArray();
@@ -88,7 +88,7 @@ public final class TestExOleObjStg {
assertEquals(src.getDataLength(), tgt.getDataLength());
- UnsynchronizedByteArrayOutputStream out = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream out = UnsynchronizedByteArrayOutputStream.builder().get();
tgt.writeOut(out);
byte[] b = out.toByteArray();
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExVideoContainer.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExVideoContainer.java
index ce02202335..a4c2a31401 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExVideoContainer.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExVideoContainer.java
@@ -67,7 +67,7 @@ public final class TestExVideoContainer {
@Test
void testWrite() throws Exception {
ExVideoContainer record = new ExVideoContainer(data, 0, data.length);
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get();
record.writeOut(baos);
assertArrayEquals(data, baos.toByteArray());
}
@@ -78,7 +78,7 @@ public final class TestExVideoContainer {
record.getExMediaAtom().setObjectId(1);
record.getPathAtom().setText("D:\\projects\\SchulerAG\\mcom_v_1_0_4\\view\\data\\tests\\images\\cards.mpg");
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get();
record.writeOut(baos);
assertArrayEquals(data, baos.toByteArray());
}
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestFontCollection.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestFontCollection.java
index a15fa80016..bb7eab1dbb 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestFontCollection.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestFontCollection.java
@@ -94,7 +94,7 @@ public final class TestFontCollection {
@Test
void testWrite() throws Exception {
FontCollection fonts = new FontCollection(data, 0, data.length);
- UnsynchronizedByteArrayOutputStream out = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream out = UnsynchronizedByteArrayOutputStream.builder().get();
fonts.writeOut(out);
byte[] recdata = out.toByteArray();
assertArrayEquals(recdata, data);
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestHeadersFootersAtom.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestHeadersFootersAtom.java
index 71ea592da2..f5cf552a5f 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestHeadersFootersAtom.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestHeadersFootersAtom.java
@@ -54,7 +54,7 @@ public final class TestHeadersFootersAtom {
@Test
void testWrite() throws Exception {
HeadersFootersAtom record = new HeadersFootersAtom(data, 0, data.length);
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get();
record.writeOut(baos);
assertArrayEquals(data, baos.toByteArray());
}
@@ -66,7 +66,7 @@ public final class TestHeadersFootersAtom {
record.setFlag(HeadersFootersAtom.fHasTodayDate, true);
record.setFlag(HeadersFootersAtom.fHasFooter, true);
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get();
record.writeOut(baos);
assertArrayEquals(data, baos.toByteArray());
}
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestHeadersFootersContainer.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestHeadersFootersContainer.java
index 21d7a83d16..209409e425 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestHeadersFootersContainer.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestHeadersFootersContainer.java
@@ -75,7 +75,7 @@ public final class TestHeadersFootersContainer {
@Test
void testWriteSlideHeadersFootersContainer() throws Exception {
HeadersFootersContainer record = new HeadersFootersContainer(slideData, 0, slideData.length);
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get();
record.writeOut(baos);
assertArrayEquals(slideData, baos.toByteArray());
}
@@ -99,7 +99,7 @@ public final class TestHeadersFootersContainer {
assertEquals(HeadersFootersContainer.FOOTERATOM, csFooter.getOptions() >> 4);
csFooter.setText("My Footer - 1");
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get();
record.writeOut(baos);
assertArrayEquals(slideData, baos.toByteArray());
}
@@ -128,7 +128,7 @@ public final class TestHeadersFootersContainer {
@Test
void testWriteNotesHeadersFootersContainer() throws Exception {
HeadersFootersContainer record = new HeadersFootersContainer(notesData, 0, notesData.length);
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get();
record.writeOut(baos);
assertArrayEquals(notesData, baos.toByteArray());
}
@@ -160,7 +160,7 @@ public final class TestHeadersFootersContainer {
assertEquals(HeadersFootersContainer.FOOTERATOM, csFooter.getOptions() >> 4);
csFooter.setText("Note Footer");
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get();
record.writeOut(baos);
assertArrayEquals(notesData, baos.toByteArray());
}
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestInteractiveInfo.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestInteractiveInfo.java
index 3e003969a9..8845e285fa 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestInteractiveInfo.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestInteractiveInfo.java
@@ -56,7 +56,7 @@ public class TestInteractiveInfo {
@Test
void testWrite() throws Exception {
InteractiveInfo ii = new InteractiveInfo(data_a, 0, data_a.length);
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get();
ii.writeOut(baos);
assertArrayEquals(data_a, baos.toByteArray());
}
@@ -74,7 +74,7 @@ public class TestInteractiveInfo {
ia.setHyperlinkType((byte)8);
// Check it's now the same as a
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get();
ii.writeOut(baos);
assertArrayEquals(data_a, baos.toByteArray());
}
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestInteractiveInfoAtom.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestInteractiveInfoAtom.java
index 824cfce1fd..1ef63efbde 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestInteractiveInfoAtom.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestInteractiveInfoAtom.java
@@ -73,7 +73,7 @@ public class TestInteractiveInfoAtom {
@Test
void testWrite() throws Exception {
InteractiveInfoAtom ia = new InteractiveInfoAtom(data_a, 0, data_a.length);
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get();
ia.writeOut(baos);
assertArrayEquals(data_a, baos.toByteArray());
}
@@ -90,7 +90,7 @@ public class TestInteractiveInfoAtom {
ia.setHyperlinkType((byte)8);
// Check it's now the same as a
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get();
ia.writeOut(baos);
assertArrayEquals(data_a, baos.toByteArray());
}
@@ -104,7 +104,7 @@ public class TestInteractiveInfoAtom {
ia.setHyperlinkID(4);
// Check bytes are now the same
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get();
ia.writeOut(baos);
assertArrayEquals(data_b, baos.toByteArray());
}
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestNotesAtom.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestNotesAtom.java
index 5528d26293..b6d7c644e7 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestNotesAtom.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestNotesAtom.java
@@ -51,7 +51,7 @@ public final class TestNotesAtom {
@Test
void testWrite() throws Exception {
NotesAtom na = new NotesAtom(data_a, 0, data_a.length);
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get();
na.writeOut(baos);
assertArrayEquals(data_a, baos.toByteArray());
}
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestSlideAtom.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestSlideAtom.java
index 366f85310f..2f5dac443f 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestSlideAtom.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestSlideAtom.java
@@ -75,7 +75,7 @@ public final class TestSlideAtom {
@Test
void testWrite() throws IOException {
SlideAtom sa = new SlideAtom(data_a, 0, data_a.length);
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get();
sa.writeOut(baos);
assertArrayEquals(data_a, baos.toByteArray());
}
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestSlidePersistAtom.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestSlidePersistAtom.java
index 4e0386d1ca..7393888034 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestSlidePersistAtom.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestSlidePersistAtom.java
@@ -52,7 +52,7 @@ public final class TestSlidePersistAtom {
@Test
void testWrite() throws Exception {
SlidePersistAtom spa = new SlidePersistAtom(data_a, 0, data_a.length);
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get();
spa.writeOut(baos);
assertArrayEquals(data_a, baos.toByteArray());
}
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestStyleTextPropAtom.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestStyleTextPropAtom.java
index 1e57798caf..e155df07b8 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestStyleTextPropAtom.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestStyleTextPropAtom.java
@@ -466,7 +466,7 @@ public final class TestStyleTextPropAtom {
tpc.setValue(0xFE0033FF);
// Should now be the same as data_a
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get();
stpa.writeOut(baos);
assertArrayEquals(data_a, baos.toByteArray());
}
@@ -615,8 +615,8 @@ public final class TestStyleTextPropAtom {
assertEquals(tpa.getValue(), tpb.getValue());
}
- UnsynchronizedByteArrayOutputStream ba = new UnsynchronizedByteArrayOutputStream();
- UnsynchronizedByteArrayOutputStream bb = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream ba = UnsynchronizedByteArrayOutputStream.builder().get();
+ UnsynchronizedByteArrayOutputStream bb = UnsynchronizedByteArrayOutputStream.builder().get();
ca.writeOut(ba);
cb.writeOut(bb);
@@ -626,7 +626,7 @@ public final class TestStyleTextPropAtom {
}
// Check byte level with b
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get();
stpa.writeOut(baos);
assertArrayEquals(data_b, baos.toByteArray());
}
@@ -674,7 +674,7 @@ public final class TestStyleTextPropAtom {
StyleTextPropAtom stpb = new StyleTextPropAtom(data, 0,data.length);
if(textlen != -1) stpb.setParentTextSize(textlen);
- UnsynchronizedByteArrayOutputStream out = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream out = UnsynchronizedByteArrayOutputStream.builder().get();
stpb.writeOut(out);
assertArrayEquals(expected, out.toByteArray());
}
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestTextBytesAtom.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestTextBytesAtom.java
index d50fc18a92..a39f4d3c42 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestTextBytesAtom.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestTextBytesAtom.java
@@ -64,7 +64,7 @@ public final class TestTextBytesAtom {
TextBytesAtom tba = new TextBytesAtom(data,0,data.length);
tba.setText(alt_text.getBytes(StandardCharsets.ISO_8859_1));
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get();
tba.writeOut(baos);
assertArrayEquals(alt_data, baos.toByteArray());
}
@@ -72,7 +72,7 @@ public final class TestTextBytesAtom {
@Test
void testWrite() throws Exception {
TextBytesAtom tba = new TextBytesAtom(data,0,data.length);
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get();
tba.writeOut(baos);
assertArrayEquals(data, baos.toByteArray());
}
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestTextCharsAtom.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestTextCharsAtom.java
index d2357a8fdc..d1b79f2234 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestTextCharsAtom.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestTextCharsAtom.java
@@ -59,7 +59,7 @@ public final class TestTextCharsAtom {
TextCharsAtom tca = new TextCharsAtom(data,0,data.length);
tca.setText(alt_text);
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get();
tca.writeOut(baos);
assertArrayEquals(alt_data, baos.toByteArray());
}
@@ -67,7 +67,7 @@ public final class TestTextCharsAtom {
@Test
void testWrite() throws Exception {
TextCharsAtom tca = new TextCharsAtom(data,0,data.length);
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get();
tca.writeOut(baos);
assertArrayEquals(data, baos.toByteArray());
}
@@ -81,7 +81,7 @@ public final class TestTextCharsAtom {
assertEquals(data_text, tca.getText());
// Check it's now like data
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get();
tca.writeOut(baos);
assertArrayEquals(data, baos.toByteArray());
}
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestTextHeaderAtom.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestTextHeaderAtom.java
index 22bce9375b..213db5f080 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestTextHeaderAtom.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestTextHeaderAtom.java
@@ -53,7 +53,7 @@ public final class TestTextHeaderAtom {
@Test
void testWrite() throws Exception {
TextHeaderAtom tha = new TextHeaderAtom(notes_data,0,12);
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get();
tha.writeOut(baos);
assertArrayEquals(notes_data, baos.toByteArray());
}
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestTextRulerAtom.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestTextRulerAtom.java
index e1a08b6e09..c9067d594e 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestTextRulerAtom.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestTextRulerAtom.java
@@ -61,7 +61,7 @@ public final class TestTextRulerAtom {
@Test
void testWriteRuler() throws Exception {
TextRulerAtom ruler = new TextRulerAtom(data_1, 0, data_1.length);
- UnsynchronizedByteArrayOutputStream out = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream out = UnsynchronizedByteArrayOutputStream.builder().get();
ruler.writeOut(out);
byte[] result = out.toByteArray();
@@ -72,7 +72,7 @@ public final class TestTextRulerAtom {
void testRead2() throws Exception {
TextRulerAtom ruler = TextRulerAtom.getParagraphInstance();
ruler.setParagraphIndent((short)249, (short)321);
- UnsynchronizedByteArrayOutputStream out = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream out = UnsynchronizedByteArrayOutputStream.builder().get();
ruler.writeOut(out);
byte[] result = out.toByteArray();
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestTextSpecInfoAtom.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestTextSpecInfoAtom.java
index c3cd26d1ce..8902d31882 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestTextSpecInfoAtom.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestTextSpecInfoAtom.java
@@ -53,7 +53,7 @@ public final class TestTextSpecInfoAtom {
@Test
void testWrite() throws Exception {
TextSpecInfoAtom spec = new TextSpecInfoAtom(data_1, 0, data_1.length);
- UnsynchronizedByteArrayOutputStream out = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream out = UnsynchronizedByteArrayOutputStream.builder().get();
spec.writeOut(out);
assertArrayEquals(data_1, out.toByteArray());
}
@@ -69,7 +69,7 @@ public final class TestTextSpecInfoAtom {
assertEquals(32, run[0].getLength());
//serialize and read again
- UnsynchronizedByteArrayOutputStream out = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream out = UnsynchronizedByteArrayOutputStream.builder().get();
spec.writeOut(out);
byte[] result = out.toByteArray();
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestTxInteractiveInfoAtom.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestTxInteractiveInfoAtom.java
index 4671e7a8aa..488e5172ad 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestTxInteractiveInfoAtom.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestTxInteractiveInfoAtom.java
@@ -57,7 +57,7 @@ public final class TestTxInteractiveInfoAtom {
@Test
void testWrite() throws Exception {
TxInteractiveInfoAtom atom = new TxInteractiveInfoAtom(data_a, 0, data_a.length);
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get();
atom.writeOut(baos);
assertArrayEquals(data_a, baos.toByteArray());
}
@@ -72,7 +72,7 @@ public final class TestTxInteractiveInfoAtom {
ia.setEndIndex(56);
// Check it's now the same as a
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get();
ia.writeOut(baos);
assertArrayEquals(data_a, baos.toByteArray());
}
@@ -87,7 +87,7 @@ public final class TestTxInteractiveInfoAtom {
ia.setEndIndex(78);
// Check bytes are now the same
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get();
ia.writeOut(baos);
assertArrayEquals(data_b, baos.toByteArray());
}
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestUserEditAtom.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestUserEditAtom.java
index a7defb0e38..be72848ee4 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestUserEditAtom.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestUserEditAtom.java
@@ -56,7 +56,7 @@ public final class TestUserEditAtom {
@Test
void testWrite() throws Exception {
UserEditAtom uea = new UserEditAtom(data_a, 0, data_a.length);
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get();
uea.writeOut(baos);
assertArrayEquals(data_a, baos.toByteArray());
}
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestHSLFSlideShow.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestHSLFSlideShow.java
index 343c1117d9..bfadc5e474 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestHSLFSlideShow.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestHSLFSlideShow.java
@@ -40,7 +40,7 @@ public class TestHSLFSlideShow extends BaseTestSlideShow<HSLFShape, HSLFTextPara
@Override
public HSLFSlideShow reopen(SlideShow<HSLFShape, HSLFTextParagraph> show) throws IOException {
- try (UnsynchronizedByteArrayOutputStream bos = new UnsynchronizedByteArrayOutputStream()) {
+ try (UnsynchronizedByteArrayOutputStream bos = UnsynchronizedByteArrayOutputStream.builder().get()) {
show.write(bos);
try (InputStream is = bos.toInputStream()) {
return new HSLFSlideShow(is);
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestPictures.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestPictures.java
index ebda0b8afa..2b90916775 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestPictures.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestPictures.java
@@ -17,7 +17,6 @@
package org.apache.poi.hslf.usermodel;
-import static org.apache.commons.io.output.NullOutputStream.NULL_OUTPUT_STREAM;
import static org.apache.poi.hslf.HSLFTestDataSamples.getSlideShow;
import static org.apache.poi.hslf.HSLFTestDataSamples.writeOutAndReadBack;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
@@ -38,6 +37,7 @@ import java.util.List;
import javax.imageio.ImageIO;
import org.apache.commons.io.output.CountingOutputStream;
+import org.apache.commons.io.output.NullOutputStream;
import org.apache.poi.POIDataSamples;
import org.apache.poi.ddf.EscherBSERecord;
import org.apache.poi.ddf.EscherContainerRecord;
@@ -315,7 +315,7 @@ public final class TestPictures {
assertEquals(PictureType.WMF, pdata.getType());
//add a new picture, it should be correctly appended to the Pictures stream
- CountingOutputStream out = new CountingOutputStream(NULL_OUTPUT_STREAM);
+ CountingOutputStream out = new CountingOutputStream(NullOutputStream.INSTANCE);
for (HSLFPictureData p : pictures) p.write(out);
int streamSize = out.getCount();
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestRichTextRun.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestRichTextRun.java
index 87fb7e0033..08d0e0e8bf 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestRichTextRun.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestRichTextRun.java
@@ -409,7 +409,7 @@ public final class TestRichTextRun {
// Now write out the slideshow
byte[] raw_ss;
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get();
s.write(baos);
try (POIFSFileSystem fs = new POIFSFileSystem(baos.toInputStream());
InputStream is = fs.createDocumentInputStream(HSLFSlideShow.POWERPOINT_DOCUMENT)) {
@@ -424,7 +424,7 @@ public final class TestRichTextRun {
}
private byte[] writeRecord( org.apache.poi.hslf.record.Record r) throws IOException {
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get();
r.writeOut(baos);
return baos.toByteArray();
}
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hsmf/TestExtractEmbeddedMSG.java b/poi-scratchpad/src/test/java/org/apache/poi/hsmf/TestExtractEmbeddedMSG.java
index c5395232dc..b7613be2da 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hsmf/TestExtractEmbeddedMSG.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hsmf/TestExtractEmbeddedMSG.java
@@ -81,7 +81,7 @@ public class TestExtractEmbeddedMSG {
testFixedAndVariableLengthPropertiesOfAttachedMSG(attachedMsg);
// rebuild top level message from embedded message
try (POIFSFileSystem extractedAttachedMsg = rebuildFromAttached(attachedMsg)) {
- try (UnsynchronizedByteArrayOutputStream extractedAttachedMsgOut = new UnsynchronizedByteArrayOutputStream()) {
+ try (UnsynchronizedByteArrayOutputStream extractedAttachedMsgOut = UnsynchronizedByteArrayOutputStream.builder().get()) {
extractedAttachedMsg.writeFilesystem(extractedAttachedMsgOut);
MAPIMessage extractedMsgTopLevel = new MAPIMessage(extractedAttachedMsgOut.toInputStream());
// test properties of rebuilt embedded message
@@ -171,7 +171,7 @@ public class TestExtractEmbeddedMSG {
MAPIType type = Types.getById(iType);
if (type != null && type != Types.UNKNOWN) {
MAPIProperty mprop = MAPIProperty.createCustom(chunk.getChunkId(), type, chunk.getEntryName());
- UnsynchronizedByteArrayOutputStream data = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream data = UnsynchronizedByteArrayOutputStream.builder().get();
chunk.writeValue(data);
PropertyValue pval = new PropertyValue(mprop, MessagePropertiesChunk.PROPERTIES_FLAG_READABLE
| MessagePropertiesChunk.PROPERTIES_FLAG_WRITEABLE, data.toByteArray(), type);
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hsmf/TestFileWithAttachmentsRead.java b/poi-scratchpad/src/test/java/org/apache/poi/hsmf/TestFileWithAttachmentsRead.java
index 068fa10883..28d02df0a0 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hsmf/TestFileWithAttachmentsRead.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hsmf/TestFileWithAttachmentsRead.java
@@ -119,7 +119,7 @@ public class TestFileWithAttachmentsRead {
assertEquals("test-unicode.doc", attachment.getAttachLongFileName().getValue());
assertEquals(".doc", attachment.getAttachExtension().getValue());
assertNull(attachment.getAttachMimeTag());
- UnsynchronizedByteArrayOutputStream attachmentstream = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream attachmentstream = UnsynchronizedByteArrayOutputStream.builder().get();
attachment.getAttachData().writeValue(attachmentstream);
assertEquals(24064, attachmentstream.size());
// or compare the hashes of the attachment data
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hsmf/TestFixedSizedProperties.java b/poi-scratchpad/src/test/java/org/apache/poi/hsmf/TestFixedSizedProperties.java
index 74d6d27ec2..9d8aa55dde 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hsmf/TestFixedSizedProperties.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hsmf/TestFixedSizedProperties.java
@@ -168,7 +168,7 @@ public final class TestFixedSizedProperties {
@Test
void testReadMessageDateSucceedsWithHSMFDump() {
HSMFDump dump = new HSMFDump(fsMessageSucceeds);
- assertDoesNotThrow(() -> dump.dump(new NullPrintStream()));
+ assertDoesNotThrow(() -> dump.dump(NullPrintStream.INSTANCE));
}
/**
@@ -177,7 +177,7 @@ public final class TestFixedSizedProperties {
@Test
void testReadMessageDateFailsWithHSMFDump() {
HSMFDump dump = new HSMFDump(fsMessageFails);
- assertDoesNotThrow(() -> dump.dump(new NullPrintStream()));
+ assertDoesNotThrow(() -> dump.dump(NullPrintStream.INSTANCE));
}
/**
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hwpf/HWPFTestCase.java b/poi-scratchpad/src/test/java/org/apache/poi/hwpf/HWPFTestCase.java
index fba8bc97c0..9a0808d286 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hwpf/HWPFTestCase.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hwpf/HWPFTestCase.java
@@ -49,7 +49,7 @@ public abstract class HWPFTestCase {
}
public HWPFDocument writeOutAndRead(HWPFDocument doc) {
- try (UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream()) {
+ try (UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get()) {
doc.write(baos);
try (InputStream is = baos.toInputStream()) {
return new HWPFDocument(is);
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hwpf/HWPFTestDataSamples.java b/poi-scratchpad/src/test/java/org/apache/poi/hwpf/HWPFTestDataSamples.java
index 0d6ce9bc8c..082b4866d4 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hwpf/HWPFTestDataSamples.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hwpf/HWPFTestDataSamples.java
@@ -48,7 +48,7 @@ public class HWPFTestDataSamples {
* Useful for verifying that the serialisation round trip
*/
public static HWPFDocument writeOutAndReadBack(HWPFDocument original) {
- try (UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream(4096)) {
+ try (UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().setBufferSize(4096).get()) {
original.write(baos);
return new HWPFDocument(baos.toInputStream());
} catch (IOException e) {
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hwpf/dev/TestHWPFLister.java b/poi-scratchpad/src/test/java/org/apache/poi/hwpf/dev/TestHWPFLister.java
index c7cd45c1cc..2c9fc68520 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hwpf/dev/TestHWPFLister.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hwpf/dev/TestHWPFLister.java
@@ -42,7 +42,7 @@ public class TestHWPFLister {
String fileArgs = SAMPLES.getFile("SampleDoc.doc").getAbsolutePath() + args;
PrintStream oldStdOut = System.out;
- System.setOut(new NullPrintStream());
+ System.setOut(NullPrintStream.INSTANCE);
try {
assertDoesNotThrow(() -> HWPFLister.main(fileArgs.split(" ")));
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hwpf/usermodel/TestHWPFWrite.java b/poi-scratchpad/src/test/java/org/apache/poi/hwpf/usermodel/TestHWPFWrite.java
index 36ad393a51..936b84317c 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hwpf/usermodel/TestHWPFWrite.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hwpf/usermodel/TestHWPFWrite.java
@@ -47,7 +47,7 @@ public final class TestHWPFWrite extends HWPFTestCase {
*/
@Test
void testWriteStream() throws IOException {
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get();
try (HWPFDocument doc = HWPFTestDataSamples.openSampleFile("SampleDoc.doc")) {
Range r = doc.getRange();
assertEquals("I am a test document\r", r.getParagraph(0).text());