Fixing migration errors: stream.read() doesn't read the entire available stream. It has to be called in a loop or replaced with readFully().

master
Stiver 10 years ago
parent a4054817d2
commit f875d27e6e
  1. 17
      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 { private static byte[] readAndClose(InputStream stream, long length) throws IOException {
try {
byte[] bytes = new byte[(int) length];
DataInputStream dataStream = new DataInputStream(stream);
try { try {
byte[] bytes = new byte[(int)length]; dataStream.readFully(bytes);
if (stream.read(bytes) != length) { } catch (EOFException ex) {
throw new IOException("premature end of stream"); throw new IOException("premature end of stream", ex);
} finally {
dataStream.close();
} }
return bytes; return bytes;
} } finally {
finally {
stream.close(); stream.close();
} }
} }

Loading…
Cancel
Save