{"record":{"id":"aee1720e1490159a","repo":"quarkusio/quarkus","slug":"error-joining-byte-arrays","errorCode":null,"errorMessage":"Error joining byte arrays","messagePattern":"Error joining byte arrays","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"core/deployment/src/main/java/io/quarkus/deployment/pkg/jar/ParallelCommonsCompressArchiveCreator.java","lineNumber":248,"sourceCode":"        } else {\n            scatterZipCreator.addArchiveEntry(zipArchiveEntry, streamSupplier);\n        }\n    }\n\n    private static byte[] joinWithNewlines(List<byte[]> lines) {\n        try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {\n            for (byte[] line : lines) {\n                if (line.length == 0) {\n                    continue;\n                }\n                out.write(line);\n                if (line[line.length - 1] != '\\n') {\n                    out.write('\\n');\n                }\n            }\n            return out.toByteArray();\n        } catch (Exception e) {\n            throw new RuntimeException(\"Error joining byte arrays\", e);\n        }\n    }\n\n    private static InputStreamSupplier toInputStreamSupplier(byte[] data) {\n        return () -> new ByteArrayInputStream(data);\n    }\n\n    private static InputStreamSupplier toInputStreamSupplier(Path path) {\n        return () -> {\n            try {\n                return Files.newInputStream(path);\n            } catch (IOException e) {\n                throw new UncheckedIOException(e);\n            }\n        };\n    }\n\n    private void normalizeTimestampsAndPermissions(ZipArchiveEntry archiveEntry) {","sourceCodeStart":230,"sourceCodeEnd":266,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/core/deployment/src/main/java/io/quarkus/deployment/pkg/jar/ParallelCommonsCompressArchiveCreator.java#L230-L266","documentation":"Thrown by joinWithNewlines in ParallelCommonsCompressArchiveCreator when concatenating multiple line byte arrays (e.g. path/class-name lists for archive entries) fails at any step, including writing the terminating newline or producing the final byte array. It wraps the underlying exception in a RuntimeException so addFile fails fast during fast-jar packaging.","triggerScenarios":"addFile is called with line data while writing joined bytes to the ByteArrayOutputStream throws, or the byte-array concatenation/loop throws (e.g. OutOfMemoryError wrapped as Exception is unlikely, but any Exception in the try block).","commonSituations":"Very large application class lists exhausting memory during package builds; disk/IO limits surfaced indirectly; custom modifications to the jar packaging pipeline.","solutions":["Look at the wrapped cause (e'getCause()') printed in the stack trace — the RuntimeException is only a wrapper.","Increase Maven memory: MAVEN_OPTS=\"-Xmx4g\" if cause is OutOfMemoryError.","Re-run the build with -Dquarkus.package.type=legacy-jar or fast-jar to rule out packaging-path-specific issues.","If reproducible only after custom code changes to the archive creator, fix the bug in the try block."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// ensure enough heap for the build\n// MAVEN_OPTS=\"-Xmx4g\" ./mvnw clean package\nSystem.out.println(Runtime.getRuntime().maxMemory() / 1024 / 1024 + \"MB heap\");","typeGuard":null,"tryCatchPattern":"try {\n    // build with fast-jar packaging\n} catch (RuntimeException e) {\n    if (\"Error joining byte arrays\".equals(e.getMessage())) {\n        log.error(\"Jar packaging failed; cause: \", e.getCause());\n        // retry with more memory or different package type\n    } else throw e;\n}","preventionTips":["Always read the wrapped cause — the message itself carries no detail.","Build with adequate heap (MAVEN_OPTS=-Xmx4g).","Avoid custom modifications to archive creators without tests.","Run mvn clean before retrying builds."],"tags":["packaging","io","byte-array"],"backgroundTag":"archive-creation-failed","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"}