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
diff --git a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/plugins/HttpPluginServlet.java b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/plugins/HttpPluginServlet.java
index 73fbb3c..4c9c59d 100644
--- a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/plugins/HttpPluginServlet.java
+++ b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/plugins/HttpPluginServlet.java
@@ -648,11 +648,9 @@
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 {