{"record":{"id":"91d31587ea67eaac","repo":"apache/flink","slug":"an-i-o-error-occurred-while-extracting-nested-libr","errorCode":null,"errorMessage":"An I/O error occurred while extracting nested library '{input.getName()}' to temporary file '{output.getAbsolutePath()}'.","messagePattern":"An I/O error occurred while extracting nested library '(.+?)' to temporary file '(.+?)'\\.","errorType":"exception","errorClass":"ProgramInvocationException","httpStatus":null,"severity":"error","filePath":"flink-clients/src/main/java/org/apache/flink/client/program/PackagedProgram.java","lineNumber":575,"sourceCode":"        } catch (Throwable t) {\n            throw new ProgramInvocationException(\n                    \"Unknown I/O error while extracting contained jar files.\", t);\n        }\n    }\n\n    private static File copyLibToTempFile(\n            String name, Random rnd, JarFile jar, JarEntry input, byte[] buffer)\n            throws ProgramInvocationException {\n        final File output = createTempFile(rnd, input, name);\n        try (final OutputStream out = new FileOutputStream(output);\n                final InputStream in = new BufferedInputStream(jar.getInputStream(input))) {\n            int numRead = 0;\n            while ((numRead = in.read(buffer)) != -1) {\n                out.write(buffer, 0, numRead);\n            }\n            return output;\n        } catch (IOException e) {\n            throw new ProgramInvocationException(\n                    \"An I/O error occurred while extracting nested library '\"\n                            + input.getName()\n                            + \"' to temporary file '\"\n                            + output.getAbsolutePath()\n                            + \"'.\");\n        }\n    }\n\n    private static File createTempFile(Random rnd, JarEntry entry, String name)\n            throws ProgramInvocationException {\n        try {\n            final File tempFile = File.createTempFile(rnd.nextInt(Integer.MAX_VALUE) + \"_\", name);\n            tempFile.deleteOnExit();\n            return tempFile;\n        } catch (IOException e) {\n            throw new ProgramInvocationException(\n                    \"An I/O error occurred while creating temporary file to extract nested library '\"\n                            + entry.getName()","sourceCodeStart":557,"sourceCodeEnd":593,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-clients/src/main/java/org/apache/flink/client/program/PackagedProgram.java#L557-L593","documentation":"Thrown when an IOException occurs while copying a nested jar entry to a temporary file during library extraction. The stream copy loop (read from JarEntry input, write to temp File output) failed. Both the source entry name and the target temp file path are included in the message for diagnosis.","triggerScenarios":"Disk full during extraction, temp file permissions revoked mid-copy, the nested jar entry is corrupt and the read fails, or the output stream is closed externally. Triggered inside copyLibToTempFile.","commonSituations":"Container /tmp volume is too small for the extracted libraries, disk quota exceeded, or the jar contains a malformed nested jar entry that causes a read error.","solutions":["Free up space in the temp directory or point java.io.tmpdir to a larger volume.","Check disk quota with 'df -h' and 'du -sh /tmp'.","Re-examine the jar for corrupt nested jars (run 'jar tf' and look for unusual entries).","If in Kubernetes, increase the emptyDir or ephemeral-storage size."],"exampleFix":"// before: default tmp dir too small\njava ... -Djava.io.tmpdir=/small/tmp\n\n// after: point to a volume with sufficient space\njava ... -Djava.io.tmpdir=/data/flink-tmp","handlingStrategy":"validation","validationCode":"File tmpDir = new File(System.getProperty(\"java.io.tmpdir\"));\nlong freeSpace = tmpDir.getUsableSpace();\nif (freeSpace < requiredBytes) {\n    throw new IllegalStateException(\"Insufficient temp space: \" + freeSpace);\n}","typeGuard":null,"tryCatchPattern":"try {\n    PackagedProgram.extractContainedLibraries(jarUrl);\n} catch (ProgramInvocationException e) {\n    if (e.getMessage().contains(\"I/O error occurred while extracting nested library\")) {\n        // check disk space and permissions\n    }\n    throw e;\n}","preventionTips":["Monitor free disk space on the temp volume.","Point java.io.tmpdir to a volume sized for the largest expected jar extraction.","In Kubernetes, size emptyDir/ephemeral-storage appropriately."],"tags":["packaged-program","io","extraction","disk-space","temp-files"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}