{"record":{"id":"1b9c6413a2b18dcb","repo":"quarkusio/quarkus","slug":"failed-to-read-all-data-for-res","errorCode":null,"errorMessage":"Failed to read all data for ${res}","messagePattern":"Failed to read all data for (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"independent-projects/bootstrap/runner/src/main/java/io/quarkus/bootstrap/runner/JarResource.java","lineNumber":84,"sourceCode":"    }\n\n    private static class JarResourceDataProvider implements JarFileReference.JarFileConsumer<byte[]> {\n        private static final JarResourceDataProvider INSTANCE = new JarResourceDataProvider();\n\n        @Override\n        public byte[] apply(JarFile jarFile, Path path, String res) {\n            ZipEntry entry = jarFile.getEntry(res);\n            if (entry == null) {\n                return null;\n            }\n            try (InputStream is = jarFile.getInputStream(entry)) {\n                byte[] data = new byte[(int) entry.getSize()];\n                int pos = 0;\n                int rem = data.length;\n                while (rem > 0) {\n                    int read = is.read(data, pos, rem);\n                    if (read == -1) {\n                        throw new RuntimeException(\"Failed to read all data for \" + res);\n                    }\n                    pos += read;\n                    rem -= read;\n                }\n                return data;\n            } catch (IOException e) {\n                throw new RuntimeException(\"Failed to read zip entry \" + res, e);\n            }\n        }\n    }\n\n    @Override\n    public URL getResourceURL(String resource) {\n        return JarFileReference.withJarFile(this, resource, JarResourceURLProvider.INSTANCE);\n    }\n\n    private static class JarResourceURLProvider implements JarFileReference.JarFileConsumer<URL> {\n        private static final JarResourceURLProvider INSTANCE = new JarResourceURLProvider();","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/bootstrap/runner/src/main/java/io/quarkus/bootstrap/runner/JarResource.java#L66-L102","documentation":"A RuntimeException thrown while fully reading a jar entry's bytes: the stream signaled EOF (read == -1) before entry.getSize() bytes were consumed. Indicates the jar entry metadata disagrees with actual data — a corrupt or truncated zip entry.","triggerScenarios":"getResourceData's stream-loading apply loop reads (int) entry.getSize() bytes from an entry input stream and hits EOF early — the jar's central directory sizes don't match the compressed data (corruption/truncation).","commonSituations":"Jar corrupted in transit (partial download/upload), jar modified in place while running, broken caching layer serving stale sizes, or disk errors.","solutions":["Validate the jar: unzip -t <jarPath>; replace it with a freshly built/installed copy (mvn clean install).","Redeploy the application to replace a truncated jar on the target host.","Check no process rewrote the jar while the app was running; stop, replace, restart.","Verify checksums of copied artifacts against build output."],"exampleFix":"// before\nscp target/quarkus-app/lib/app.jar host:/deploy/lib/  # interrupted\n// after\nscp target/quarkus-app/lib/app.jar host:/tmp/ && ssh host 'unzip -t /tmp/app.jar && mv /tmp/app.jar /deploy/lib/'","handlingStrategy":"validation","validationCode":"try (var zf = new java.util.zip.ZipFile(jar.toFile())) {\n  for (var en = zf.entries(); en.hasMoreElements(); ) { if (!zf.getInputStream(en.nextElement()).transferTo(java.io.OutputStream.nullOutputStream())) return false; }\n  return true;\n}","typeGuard":"boolean jarEntriesIntact(Path p) { try (var zf = new java.util.zip.ZipFile(p.toFile())) { return zf.size() > 0; } catch (Exception e) { return false; } }","tryCatchPattern":"try { app.start(); } catch (RuntimeException e) { if (e.getMessage() != null && e.getMessage().startsWith(\"Failed to read all data for \")) { log.error(\"Corrupt zip entry — replace jar\", e); throw new IllegalStateException(\"Redeploy verified jar\", e); } throw e; }","preventionTips":["Verify checksums of artifacts after every transfer.","Use unzip -t in deployment smoke tests.","Never modify jars in place while the app runs.","Watch for disk errors on hosts (dmesg)."],"tags":["jar","corruption","truncated-data"],"backgroundTag":"stream-truncated","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}