mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[^ann] IDEA-86873 Out of memory exception when trying to manage file encodings
(cherry-picked from d9908e4)
This commit is contained in:
+4
@@ -29,6 +29,7 @@ import com.intellij.openapi.vfs.encoding.EncodingManager;
|
||||
import com.intellij.openapi.vfs.encoding.EncodingRegistry;
|
||||
import com.intellij.openapi.vfs.newvfs.NewVirtualFile;
|
||||
import com.intellij.openapi.vfs.newvfs.persistent.PersistentFS;
|
||||
import com.intellij.psi.SingleRootFileViewProvider;
|
||||
import com.intellij.util.io.IOUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -440,6 +441,9 @@ public abstract class VirtualFileSystemEntry extends NewVirtualFile {
|
||||
charset = configured == null ? Charset.defaultCharset() : configured;
|
||||
setCharset(charset);
|
||||
}
|
||||
else if (SingleRootFileViewProvider.isTooLargeForContentLoading(this)) {
|
||||
charset = super.getCharset();
|
||||
}
|
||||
else {
|
||||
try {
|
||||
final byte[] content;
|
||||
|
||||
@@ -367,10 +367,6 @@ public class FileUtilRt {
|
||||
|
||||
@NotNull
|
||||
public static byte[] loadBytes(@NotNull InputStream stream, int length) throws IOException {
|
||||
if (isTooLarge(length)) {
|
||||
throw new FileTooBigException("Too large file, size is " + length + " bytes.");
|
||||
}
|
||||
|
||||
byte[] bytes = new byte[length];
|
||||
int count = 0;
|
||||
while (count < length) {
|
||||
|
||||
Reference in New Issue
Block a user