From f875d27e6e2086888cc3c4d837872b11b58dd8fc Mon Sep 17 00:00:00 2001 From: Stiver Date: Sun, 28 Sep 2014 09:00:31 +0200 Subject: Fixing migration errors: stream.read() doesn't read the entire available stream. It has to be called in a loop or replaced with readFully(). --- .../jetbrains/java/decompiler/util/InterpreterUtil.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'src') 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(); } } -- cgit v1.2.3