You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2024/02/17 22:16:26 UTC
(commons-compress) 04/14: Reuse IOUtils.readRange()
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git
commit 9399923c47e7dd9b2a202be21770b4d42dcdddda
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Feb 17 10:10:48 2024 -0500
Reuse IOUtils.readRange()
---
.../apache/commons/compress/harmony/unpack200/FileBands.java | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/src/main/java/org/apache/commons/compress/harmony/unpack200/FileBands.java b/src/main/java/org/apache/commons/compress/harmony/unpack200/FileBands.java
index e6db16fda..6aab4eed5 100644
--- a/src/main/java/org/apache/commons/compress/harmony/unpack200/FileBands.java
+++ b/src/main/java/org/apache/commons/compress/harmony/unpack200/FileBands.java
@@ -73,18 +73,16 @@ public class FileBands extends BandSet {
}
// TODO: stream the file bits directly somehow
- public void processFileBits() throws IOException, Pack200Exception {
+ public void processFileBits() throws IOException {
// now read in the bytes
final int numberOfFiles = header.getNumberOfFiles();
fileBits = new byte[numberOfFiles][];
for (int i = 0; i < numberOfFiles; i++) {
final int size = (int) fileSize[i];
- // TODO This breaks if file_size > 2^32. Probably an array is
- // not the right choice, and we should just serialize it here?
- fileBits[i] = new byte[size];
- final int read = IOUtils.readFully(in, fileBits[i]);
+ fileBits[i] = IOUtils.readRange(in, size);
+ final int read = fileBits[i].length;
if (size != 0 && read < size) {
- throw new Pack200Exception("Expected to read " + size + " bytes but read " + read);
+ throw new IOException("Expected to read " + size + " bytes but read " + read);
}
}
}