diff options
author | PJ Fanning <fanningpj@apache.org> | 2022-02-19 22:01:50 +0000 |
---|---|---|
committer | PJ Fanning <fanningpj@apache.org> | 2022-02-19 22:01:50 +0000 |
commit | 0482dc61e19540ca0f0bd9782449285e5987218f (patch) | |
tree | db29f30d46930b47ba6346f280dbadd8eea47c67 /poi/src | |
parent | 60f0c0a7f5d284c908a3e7e6051ecde3e10c1872 (diff) | |
download | poi-0482dc61e19540ca0f0bd9782449285e5987218f.tar.gz poi-0482dc61e19540ca0f0bd9782449285e5987218f.zip |
revert IOUtils change
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1898236 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi/src')
-rw-r--r-- | poi/src/main/java/org/apache/poi/util/IOUtils.java | 21 | ||||
-rw-r--r-- | poi/src/test/java/org/apache/poi/util/TestIOUtils.java | 4 |
2 files changed, 10 insertions, 15 deletions
diff --git a/poi/src/main/java/org/apache/poi/util/IOUtils.java b/poi/src/main/java/org/apache/poi/util/IOUtils.java index fa4cb785bd..f220d34665 100644 --- a/poi/src/main/java/org/apache/poi/util/IOUtils.java +++ b/poi/src/main/java/org/apache/poi/util/IOUtils.java @@ -96,10 +96,6 @@ public final class IOUtils { } } - private static int getByteArrayLimit() { - return BYTE_ARRAY_MAX_OVERRIDE < 0 ? Integer.MAX_VALUE : BYTE_ARRAY_MAX_OVERRIDE; - } - /** * Peeks at the first N bytes of the stream. Returns those bytes, but * with the stream unaffected. Requires a stream that supports mark/reset, @@ -134,15 +130,14 @@ public final class IOUtils { } /** - * Reads all the data from the input stream, and returns the bytes read. If {@link #setByteArrayMaxOverride(int)} - * is used then that limit is applied and this call will fail if the array size exceeds the configured limit. + * Reads all the data from the input stream, and returns the bytes read. * * @param stream The byte stream of data to read. * @return A byte array with the read bytes. * @throws IOException If reading data fails or EOF is encountered too early for the given length. */ public static byte[] toByteArray(InputStream stream) throws IOException { - return toByteArray(stream, getByteArrayLimit()); + return toByteArray(stream, Integer.MAX_VALUE); } /** @@ -155,7 +150,7 @@ public final class IOUtils { * @throws IOException If reading data fails or EOF is encountered too early for the given length. */ public static byte[] toByteArray(InputStream stream, final int length) throws IOException { - return toByteArray(stream, length, getByteArrayLimit()); + return toByteArray(stream, length, Integer.MAX_VALUE); } @@ -537,11 +532,11 @@ public final class IOUtils { private static void throwRFE(long length, int maxLength) { throw new RecordFormatException(String.format(Locale.ROOT, "Tried to allocate an array of length %,d" + - ", but the maximum length for this record type is %,d.\n" + - "If the file is not corrupt, please open an issue on bugzilla to request \n" + - "increasing the maximum allowable size for this record type.\n"+ - "As a temporary workaround, consider setting a higher override value with " + - "IOUtils.setByteArrayMaxOverride()", + ", but the maximum length for this record type is %,d.\n" + + "If the file is not corrupt, please open an issue on bugzilla to request \n" + + "increasing the maximum allowable size for this record type.\n"+ + "As a temporary workaround, consider setting a higher override value with " + + "IOUtils.setByteArrayMaxOverride()", length, maxLength)); } diff --git a/poi/src/test/java/org/apache/poi/util/TestIOUtils.java b/poi/src/test/java/org/apache/poi/util/TestIOUtils.java index 077755c591..01ed21ecbf 100644 --- a/poi/src/test/java/org/apache/poi/util/TestIOUtils.java +++ b/poi/src/test/java/org/apache/poi/util/TestIOUtils.java @@ -100,12 +100,12 @@ final class TestIOUtils { } @Test - void testToByteArrayToSmall() { + void testToByteArrayTooSmall() { assertThrows(IOException.class, () -> IOUtils.toByteArray(data123(), 10)); } @Test - void testToByteArrayMaxLengthToSmall() { + void testToByteArrayMaxLengthTooSmall() { assertThrows(IOException.class, () -> IOUtils.toByteArray(data123(), 10, 10)); } |