diff --git a/src/java/org/apache/poi/poifs/storage/DocumentBlock.java b/src/java/org/apache/poi/poifs/storage/DocumentBlock.java index f6d0d92b4..7af3487fa 100644 --- a/src/java/org/apache/poi/poifs/storage/DocumentBlock.java +++ b/src/java/org/apache/poi/poifs/storage/DocumentBlock.java @@ -62,6 +62,7 @@ import java.io.OutputStream; import java.util.Arrays; import org.apache.poi.poifs.common.POIFSConstants; +import org.apache.poi.util.IOUtils; import org.apache.poi.util.IntegerField; import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndianConsts; @@ -106,7 +107,7 @@ public class DocumentBlock throws IOException { this(); - int count = stream.read(_data); + int count = IOUtils.readFully(stream, _data); _bytes_read = (count == -1) ? 0 : count; diff --git a/src/java/org/apache/poi/poifs/storage/HeaderBlockReader.java b/src/java/org/apache/poi/poifs/storage/HeaderBlockReader.java index 015d455d2..ad7736851 100644 --- a/src/java/org/apache/poi/poifs/storage/HeaderBlockReader.java +++ b/src/java/org/apache/poi/poifs/storage/HeaderBlockReader.java @@ -60,6 +60,7 @@ import java.io.*; import java.util.*; import org.apache.poi.poifs.common.POIFSConstants; +import org.apache.poi.util.IOUtils; import org.apache.poi.util.IntegerField; import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndianConsts; @@ -104,7 +105,7 @@ public class HeaderBlockReader throws IOException { _data = new byte[ POIFSConstants.BIG_BLOCK_SIZE ]; - int byte_count = stream.read(_data); + int byte_count = IOUtils.readFully(stream, _data); if (byte_count != POIFSConstants.BIG_BLOCK_SIZE) { diff --git a/src/java/org/apache/poi/poifs/storage/RawDataBlock.java b/src/java/org/apache/poi/poifs/storage/RawDataBlock.java index 862fd8ca2..863b6108e 100644 --- a/src/java/org/apache/poi/poifs/storage/RawDataBlock.java +++ b/src/java/org/apache/poi/poifs/storage/RawDataBlock.java @@ -56,6 +56,7 @@ package org.apache.poi.poifs.storage; import org.apache.poi.poifs.common.POIFSConstants; +import org.apache.poi.util.IOUtils; import java.io.*; @@ -84,7 +85,7 @@ public class RawDataBlock throws IOException { _data = new byte[ POIFSConstants.BIG_BLOCK_SIZE ]; - int count = stream.read(_data); + int count = IOUtils.readFully(stream, _data); if (count == -1) { diff --git a/src/testcases/org/apache/poi/poifs/filesystem/TestDocument.java b/src/testcases/org/apache/poi/poifs/filesystem/TestDocument.java index af417fad1..2e9fd0282 100644 --- a/src/testcases/org/apache/poi/poifs/filesystem/TestDocument.java +++ b/src/testcases/org/apache/poi/poifs/filesystem/TestDocument.java @@ -107,7 +107,7 @@ public class TestDocument { array[ j ] = ( byte ) j; } - document = new POIFSDocument("foo", new ByteArrayInputStream(array)); + document = new POIFSDocument("foo", new SlowInputStream(new ByteArrayInputStream(array))); checkDocument(document, array); // verify correct number of blocks get created for document