diff options
author | Stiver <stiver.mail@gmail.com> | 2014-09-28 09:00:31 +0200 |
---|---|---|
committer | Stiver <stiver.mail@gmail.com> | 2014-09-28 09:00:31 +0200 |
commit | f875d27e6e2086888cc3c4d837872b11b58dd8fc (patch) | |
tree | 535437f0ce40c9ab69cf3ffef3b6116701a2f634 /src | |
parent | a4054817d2bf2ce5a2367ca1538ab90ce5358713 (diff) | |
download | fernflower-f875d27e6e2086888cc3c4d837872b11b58dd8fc.tar fernflower-f875d27e6e2086888cc3c4d837872b11b58dd8fc.tar.gz fernflower-f875d27e6e2086888cc3c4d837872b11b58dd8fc.tar.lz fernflower-f875d27e6e2086888cc3c4d837872b11b58dd8fc.tar.xz fernflower-f875d27e6e2086888cc3c4d837872b11b58dd8fc.zip |
Fixing migration errors: stream.read() doesn't read the entire available stream. It has to be called in a loop or replaced with readFully().
Diffstat (limited to 'src')
-rw-r--r-- | src/org/jetbrains/java/decompiler/util/InterpreterUtil.java | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/org/jetbrains/java/decompiler/util/InterpreterUtil.java b/src/org/jetbrains/java/decompiler/util/InterpreterUtil.java index 0047bb7..0644b69 100644 --- a/src/org/jetbrains/java/decompiler/util/InterpreterUtil.java +++ b/src/org/jetbrains/java/decompiler/util/InterpreterUtil.java @@ -70,14 +70,21 @@ public class InterpreterUtil { } private static byte[] readAndClose(InputStream stream, long length) throws IOException { + try { - byte[] bytes = new byte[(int)length]; - if (stream.read(bytes) != length) { - throw new IOException("premature end of stream"); + byte[] bytes = new byte[(int) length]; + DataInputStream dataStream = new DataInputStream(stream); + + try { + dataStream.readFully(bytes); + } catch (EOFException ex) { + throw new IOException("premature end of stream", ex); + } finally { + dataStream.close(); } + return bytes; - } - finally { + } finally { stream.close(); } } |