{"record":{"id":"fb643ec726028fdc","repo":"apache/flink","slug":"unknown-i-o-error-while-extracting-contained-jar-f","errorCode":null,"errorMessage":"Unknown I/O error while extracting contained jar files.","messagePattern":"Unknown I/O error while extracting contained jar files\\.","errorType":"exception","errorClass":"ProgramInvocationException","httpStatus":null,"severity":"error","filePath":"flink-clients/src/main/java/org/apache/flink/client/program/PackagedProgram.java","lineNumber":558,"sourceCode":"                for (final JarEntry entry : containedJarFileEntries) {\n                    // '/' as in case of zip, jar\n                    // java.util.zip.ZipEntry#isDirectory always looks only for '/' not for\n                    // File.separator\n                    final String name = entry.getName().replace('/', '_');\n                    final File tempFile = copyLibToTempFile(name, rnd, jar, entry, buffer);\n                    extractedTempLibraries.add(tempFile);\n                }\n\n                incomplete = false;\n            } finally {\n                if (incomplete) {\n                    deleteExtractedLibraries(extractedTempLibraries);\n                }\n            }\n\n            return extractedTempLibraries;\n        } 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 '\"","sourceCodeStart":540,"sourceCodeEnd":576,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-clients/src/main/java/org/apache/flink/client/program/PackagedProgram.java#L540-L576","documentation":"A catch-all (Throwable) wrapping any failure during extractContainedLibraries. This method opens a JarFile and copies every contained nested jar to temp files; if anything in that process throws (IO, security, or otherwise), it is wrapped here. It is a broad safety net around the entire extraction routine.","triggerScenarios":"Calling PackagedProgram.extractContainedLibraries(jarUrl) when the jar is corrupt, unreadable, the temp directory is full, or a security manager blocks file access. Also triggered if new JarFile(toURI) fails because the URL cannot be converted back to a file path.","commonSituations":"Corrupt or truncated jar (failed upload/download), jar on a network filesystem that becomes unavailable, /tmp full or read-only in a container, or security manager restrictions.","solutions":["Verify the jar is a valid zip: 'unzip -t your.jar'.","Check that the system temp directory (java.io.tmpdir) is writable and has space.","If running in a container, ensure /tmp is mounted as writable storage.","Re-download or re-build the jar to rule out corruption."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if (!jarFile.exists() || !jarFile.isFile()) {\n    throw new IllegalArgumentException(\"Jar does not exist: \" + jarFile);\n}\nFile tmpDir = new File(System.getProperty(\"java.io.tmpdir\"));\nif (!tmpDir.canWrite()) {\n    throw new IllegalStateException(\"Temp dir not writable: \" + tmpDir);\n}","typeGuard":null,"tryCatchPattern":"try {\n    List<File> libs = PackagedProgram.extractContainedLibraries(jarUrl);\n} catch (ProgramInvocationException e) {\n    // inspect cause for corrupt jar / disk full / permissions\n    throw e;\n}","preventionTips":["Validate jar integrity with 'unzip -t' before deployment.","Ensure java.io.tmpdir is writable and has adequate free space.","Use complete, uncorrupted jar distributions."],"tags":["packaged-program","jar","io","extraction","temp-files"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}