HttpPluginServlet: Fix "short read of block" IO error on plugin docs

When accessing plugins static resources from the Jar, treat the
JarEntry size as a "hint" to the expected uncompressed size, rather
than the exact size.

Treating as "exact value" can result in an IO error whilst reading
the resource:

  java.io.EOFException: Short read of block

Change-Id: I6b488e58bb34620483d9ed7524ac3c23ce44071a
This commit is contained in:
Luca Milanesio 2015-11-20 13:53:53 +00:00 committed by David Pursehouse
parent bedd4eaf84
commit 4554d27f27

View File

@ -648,11 +648,9 @@ class HttpPluginServlet extends HttpServlet
private static byte[] readWholeEntry(PluginContentScanner scanner, PluginEntry entry)
throws IOException {
byte[] data = new byte[entry.getSize().get().intValue()];
try (InputStream in = scanner.getInputStream(entry)) {
IO.readFully(in, data, 0, data.length);
return IO.readWholeStream(in, entry.getSize().get().intValue()).array();
}
return data;
}
private static class PluginHolder {