From f56eea8e45522cb497074ba9861f523705a9c7f2 Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Wed, 5 Jun 2024 16:31:36 +0000 Subject: BoundedInputStream deprecation warnings git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1918175 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/main/java/org/apache/poi/hslf/record/ExOleObjStg.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'poi-scratchpad') 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 2849601612..dfff540574 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 @@ -21,6 +21,7 @@ import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.io.UncheckedIOException; import java.util.Arrays; import java.util.Map; import java.util.function.Supplier; @@ -102,13 +103,21 @@ public class ExOleObjStg extends PositionDependentRecordAtom implements PersistR * Opens an input stream which will decompress the data on the fly. * * @return the data input stream. + * @throws UncheckedIOException if the data size exceeds the expected size. */ public InputStream getData() { if (isCompressed()) { int size = LittleEndian.getInt(_data); InputStream compressedStream = new ByteArrayInputStream(_data, 4, _data.length); - return new BoundedInputStream(new InflaterInputStream(compressedStream), size); + try { + return BoundedInputStream.builder() + .setInputStream(new InflaterInputStream(compressedStream)) + .setMaxCount(size) + .get(); + } catch (IOException e) { + throw new UncheckedIOException(e); + } } else { return new ByteArrayInputStream(_data, 0, _data.length); } -- cgit v1.2.3