Buffer input streams to ensure data is read from OS in whole blocks (IDEA-141576)

This commit is contained in:
Jim Purbrick
2015-06-17 20:23:58 +03:00
committed by Roman Shevchenko
parent 268a811858
commit 2ff8987b3c
2 changed files with 3 additions and 1 deletions
@@ -25,6 +25,7 @@ import com.intellij.util.text.ByteArrayCharSequence;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.BufferedInputStream;
import java.io.Closeable;
import java.io.File;
import java.io.IOException;
@@ -194,6 +195,7 @@ public class ZipHandler extends ArchiveHandler {
if (entry != null) {
InputStream stream = zip.getInputStream(entry);
if (stream != null) {
stream = new BufferedInputStream(stream);
try {
return FileUtil.loadBytes(stream, (int)entry.getSize());
}
@@ -476,7 +476,7 @@ public abstract class LocalFileSystemBase extends LocalFileSystem {
@Override
@NotNull
public byte[] contentsToByteArray(@NotNull final VirtualFile file) throws IOException {
final FileInputStream stream = new FileInputStream(convertToIOFileAndCheck(file));
final InputStream stream = new BufferedInputStream(new FileInputStream(convertToIOFileAndCheck(file)));
try {
long l = file.getLength();
if (l > Integer.MAX_VALUE) throw new IOException("File is too large: " + l + ", " + file);