Author: fanningpj
Date: Wed Jun  5 16:31:36 2024
New Revision: 1918175

URL: http://svn.apache.org/viewvc?rev=1918175&view=rev
Log:
BoundedInputStream deprecation warnings

Modified:
    
poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ExOleObjStg.java
    
poi/trunk/poi/src/main/java/org/apache/poi/poifs/crypt/cryptoapi/CryptoAPIDecryptor.java
    
poi/trunk/poi/src/main/java/org/apache/poi/poifs/crypt/cryptoapi/CryptoAPIDocumentOutputStream.java
    
poi/trunk/poi/src/main/java/org/apache/poi/poifs/crypt/standard/StandardDecryptor.java
    poi/trunk/poi/src/main/java/org/apache/poi/util/IOUtils.java

Modified: 
poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ExOleObjStg.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ExOleObjStg.java?rev=1918175&r1=1918174&r2=1918175&view=diff
==============================================================================
--- 
poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ExOleObjStg.java
 (original)
+++ 
poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ExOleObjStg.java
 Wed Jun  5 16:31:36 2024
@@ -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 Positio
      * 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);
         }

Modified: 
poi/trunk/poi/src/main/java/org/apache/poi/poifs/crypt/cryptoapi/CryptoAPIDecryptor.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/poifs/crypt/cryptoapi/CryptoAPIDecryptor.java?rev=1918175&r1=1918174&r2=1918175&view=diff
==============================================================================
--- 
poi/trunk/poi/src/main/java/org/apache/poi/poifs/crypt/cryptoapi/CryptoAPIDecryptor.java
 (original)
+++ 
poi/trunk/poi/src/main/java/org/apache/poi/poifs/crypt/cryptoapi/CryptoAPIDecryptor.java
 Wed Jun  5 16:31:36 2024
@@ -205,7 +205,7 @@ public class CryptoAPIDecryptor extends
             for (StreamDescriptorEntry entry : entries) {
                 sbis.seek(entry.streamOffset);
                 sbis.setBlock(entry.block);
-                try (InputStream is = new BoundedInputStream(sbis, 
entry.streamSize)) {
+                try (InputStream is = 
BoundedInputStream.builder().setInputStream(sbis).setMaxCount(entry.streamSize).get())
 {
                     fsOut.createDocument(is, entry.streamName);
                 }
             }

Modified: 
poi/trunk/poi/src/main/java/org/apache/poi/poifs/crypt/cryptoapi/CryptoAPIDocumentOutputStream.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/poifs/crypt/cryptoapi/CryptoAPIDocumentOutputStream.java?rev=1918175&r1=1918174&r2=1918175&view=diff
==============================================================================
--- 
poi/trunk/poi/src/main/java/org/apache/poi/poifs/crypt/cryptoapi/CryptoAPIDocumentOutputStream.java
 (original)
+++ 
poi/trunk/poi/src/main/java/org/apache/poi/poifs/crypt/cryptoapi/CryptoAPIDocumentOutputStream.java
 Wed Jun  5 16:31:36 2024
@@ -16,7 +16,9 @@
 ==================================================================== */
 package org.apache.poi.poifs.crypt.cryptoapi;
 
+import java.io.IOException;
 import java.io.InputStream;
+import java.io.UncheckedIOException;
 import java.security.GeneralSecurityException;
 
 import javax.crypto.Cipher;
@@ -40,8 +42,22 @@ import org.apache.poi.util.Internal;
         cipher = encryptor.initCipherForBlock(null, 0);
     }
 
+    /**
+     * Returns the encrypted data.
+     *
+     * @param maxSize
+     * @return the encrypted data
+     * @throws UncheckedIOException if an I/O error occurs
+     */
     public InputStream toInputStream(long maxSize) {
-        return new BoundedInputStream(toInputStream(), maxSize);
+        try {
+            return BoundedInputStream.builder()
+                .setInputStream(toInputStream())
+                .setMaxCount(maxSize)
+                .get();
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
     }
 
     public void setSize(int count) {

Modified: 
poi/trunk/poi/src/main/java/org/apache/poi/poifs/crypt/standard/StandardDecryptor.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/poifs/crypt/standard/StandardDecryptor.java?rev=1918175&r1=1918174&r2=1918175&view=diff
==============================================================================
--- 
poi/trunk/poi/src/main/java/org/apache/poi/poifs/crypt/standard/StandardDecryptor.java
 (original)
+++ 
poi/trunk/poi/src/main/java/org/apache/poi/poifs/crypt/standard/StandardDecryptor.java
 Wed Jun  5 16:31:36 2024
@@ -140,8 +140,14 @@ public class StandardDecryptor extends D
         long cipherLen = (_length/blockSize + 1) * blockSize;
         Cipher cipher = getCipher(getSecretKey());
 
-        InputStream boundedDis = new BoundedInputStream(dis, cipherLen);
-        return new BoundedInputStream(new CipherInputStream(boundedDis, 
cipher), _length);
+        final InputStream boundedDis = BoundedInputStream.builder()
+            .setInputStream(dis)
+            .setMaxCount(cipherLen)
+            .get();
+        return BoundedInputStream.builder()
+            .setInputStream(new CipherInputStream(boundedDis, cipher))
+            .setMaxCount(_length)
+            .get();
     }
 
     /**

Modified: poi/trunk/poi/src/main/java/org/apache/poi/util/IOUtils.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/util/IOUtils.java?rev=1918175&r1=1918174&r2=1918175&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/util/IOUtils.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/util/IOUtils.java Wed Jun  5 
16:31:36 2024
@@ -142,7 +142,7 @@ public final class IOUtils {
 
         stream.mark(limit);
         try (UnsynchronizedByteArrayOutputStream bos = 
UnsynchronizedByteArrayOutputStream.builder().setBufferSize(limit).get()) {
-            copy(new BoundedInputStream(stream, limit), bos);
+            
copy(BoundedInputStream.builder().setInputStream(stream).setMaxCount(limit).get(),
 bos);
 
             int readBytes = bos.size();
             if (readBytes == 0) {



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

Reply via email to