{"record":{"id":"ee0016be88b48cd6","repo":"quarkusio/quarkus","slug":"unexpected-end-of-stream-while-reading-application","errorCode":null,"errorMessage":"Unexpected end of stream while reading application config file: ${resourceName}","messagePattern":"Unexpected end of stream while reading application config file: (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"independent-projects/bootstrap/runner/src/main/java/io/quarkus/bootstrap/runner/AotSerializedApplication.java","lineNumber":363,"sourceCode":"        } else {\n            List<ApplicationConfigEntry> entries = new ArrayList<>(jarEntryCount);\n            for (int j = 0; j < jarEntryCount; j++) {\n                String url = data.readUTF();\n                int dataLength = data.readInt();\n                byte[] content = readBytes(data, dataLength, configFileName);\n                entries.add(new ApplicationConfigEntry(url, content));\n            }\n            return entries;\n        }\n    }\n\n    private static byte[] readBytes(DataInputStream data, int length, String resourceName) throws IOException {\n        byte[] content = new byte[length];\n        int totalRead = 0;\n        while (totalRead < length) {\n            int read = data.read(content, totalRead, length - totalRead);\n            if (read == -1) {\n                throw new IOException(\n                        \"Unexpected end of stream while reading application config file: \" + resourceName);\n            }\n            totalRead += read;\n        }\n        return content;\n    }\n}\n","sourceCodeStart":345,"sourceCodeEnd":371,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/bootstrap/runner/src/main/java/io/quarkus/bootstrap/runner/AotSerializedApplication.java#L345-L371","documentation":"An IOException thrown by the AOT deserializer's readBytes helper when the serialized application stream ends before the declared number of bytes for an application config entry could be read. It means the serialized application image (.dat file) is truncated or written by an incompatible writer.","triggerScenarios":"readBytes, called while deserializing application config entries (content/content1/content2), hits EOF (read == -1) before reading `length` bytes — a short/aborted write or corrupted serialized image.","commonSituations":"The serialized app file was truncated by disk-full or killed build process; the image was produced by a different Quarkus version with a changed format; manual copy/partial upload of the image artifact.","solutions":["Regenerate the serialized application image by re-running the package/AOT build (mvn clean package).","Verify the image file size matches the artifact produced by the build (re-deploy if copied).","Ensure the Quarkus runtime version matches the version that produced the image (check VERSION compatibility).","Check build logs for earlier failures (e.g. disk-full) that aborted serialization."],"exampleFix":"// before\ncp app.dat /deploy/app.dat  # partially copied\n// after\nmvn clean package && sha256sum target/*.dat && cp target/*.dat /deploy/app.dat && sha256sum /deploy/app.dat","handlingStrategy":"validation","validationCode":"Path img = Path.of(\"app.dat\");\nif (!Files.isRegularFile(img) || Files.size(img) == 0) throw new IllegalStateException(\"serialized app image missing or empty: \" + img);\n// compare against expected checksum from build if available","typeGuard":"boolean looksLikeSerializedApp(Path p) throws IOException { try (var in = new DataInputStream(Files.newInputStream(p))) { return in.available() >= 4; } }","tryCatchPattern":"try { app.start(); } catch (IOException e) { if (e.getMessage().startsWith(\"Unexpected end of stream\")) { log.error(\"Truncated serialized image: regenerate it\", e); throw new IllegalStateException(\"Re-run package build\", e); } throw e; }","preventionTips":["Regenerate the image on every Quarkus version change.","Copy artifacts with checksum verification.","Monitor build logs for serialization aborts.","Deploy whole artifact sets atomically, not file-by-file."],"tags":["io","deserialization","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-12T22:17:10.623Z"}