mirror of
https://github.com/moparisthebest/fernflower
synced 2024-11-23 01:32:21 -05:00
Fixing migration errors: stream.read() doesn't read the entire available stream. It has to be called in a loop or replaced with readFully().
This commit is contained in:
parent
a4054817d2
commit
f875d27e6e
@ -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 {
|
try {
|
||||||
byte[] bytes = new byte[(int)length];
|
byte[] bytes = new byte[(int) length];
|
||||||
if (stream.read(bytes) != length) {
|
DataInputStream dataStream = new DataInputStream(stream);
|
||||||
throw new IOException("premature end of stream");
|
|
||||||
|
try {
|
||||||
|
dataStream.readFully(bytes);
|
||||||
|
} catch (EOFException ex) {
|
||||||
|
throw new IOException("premature end of stream", ex);
|
||||||
|
} finally {
|
||||||
|
dataStream.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
return bytes;
|
return bytes;
|
||||||
}
|
} finally {
|
||||||
finally {
|
|
||||||
stream.close();
|
stream.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user