mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-10-02 00:57:59 +07:00
Buffer input streams to ensure data is read from OS in whole blocks (IDEA-141576)
This commit is contained in:
committed by
Roman Shevchenko
parent
268a811858
commit
2ff8987b3c
@@ -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());
|
||||
}
|
||||
|
||||
+1
-1
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user