aboutsummaryrefslogtreecommitdiffstats
path: root/src/java
diff options
context:
space:
mode:
authorDominik Stadler <centic@apache.org>2021-01-06 09:10:28 +0000
committerDominik Stadler <centic@apache.org>2021-01-06 09:10:28 +0000
commitc1397afbf3cf9c51a20357e3c49c1e7c2b8f61fc (patch)
treefe0fb2818dfeff002bd600788cb9626d4031c35a /src/java
parentda7725e3d643bfa96b5e1c2a66f52022538b34f2 (diff)
downloadpoi-c1397afbf3cf9c51a20357e3c49c1e7c2b8f61fc.tar.gz
poi-c1397afbf3cf9c51a20357e3c49c1e7c2b8f61fc.zip
Slightly adjust error message if requested allocations are too big
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1885189 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java')
-rw-r--r--src/java/org/apache/poi/util/IOUtils.java10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/java/org/apache/poi/util/IOUtils.java b/src/java/org/apache/poi/util/IOUtils.java
index f1532b75e2..26a720ab98 100644
--- a/src/java/org/apache/poi/util/IOUtils.java
+++ b/src/java/org/apache/poi/util/IOUtils.java
@@ -29,6 +29,7 @@ import java.io.PushbackInputStream;
import java.nio.ByteBuffer;
import java.nio.channels.ReadableByteChannel;
import java.util.Arrays;
+import java.util.Locale;
import java.util.zip.CRC32;
import java.util.zip.Checksum;
@@ -173,7 +174,7 @@ public final class IOUtils {
checkLength(length, maxLength);
}
- final int len = Math.min((int)length, maxLength);
+ final int len = Math.min(length, maxLength);
ByteArrayOutputStream baos = new ByteArrayOutputStream(len == Integer.MAX_VALUE ? 4096 : len);
byte[] buffer = new byte[4096];
@@ -508,12 +509,13 @@ public final class IOUtils {
}
private static void throwRFE(long length, int maxLength) {
- throw new RecordFormatException("Tried to allocate an array of length "+length +
- ", but "+ maxLength+" is the maximum for this record type.\n" +
+ throw new RecordFormatException(String.format(Locale.ROOT, "Tried to allocate an array of length %,d" +
+ ", but the maximum lenght 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()");
+ "IOUtils.setByteArrayMaxOverride()",
+ length, maxLength));
}
}