{"record":{"id":"7f00571c991787f7","repo":"skylot/jadx","slug":"failed-to-open-input-stream-for-entry","errorCode":null,"errorMessage":"Failed to open input stream for entry: {}","messagePattern":"Failed to open input stream for entry: (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"jadx-commons/jadx-zip/src/main/java/jadx/zip/fallback/FallbackZipParser.java","lineNumber":86,"sourceCode":"\t\tif (!validEntry) {\n\t\t\tLOG.warn(\"Zip entry '{}' is invalid and excluded from processing\", zipEntry);\n\t\t}\n\t\treturn validEntry;\n\t}\n\n\tpublic byte[] getBytes(FallbackZipEntry entry) {\n\t\ttry (InputStream is = getEntryStream(entry)) {\n\t\t\treturn is.readAllBytes();\n\t\t} catch (Exception e) {\n\t\t\tthrow new RuntimeException(\"Failed to read bytes for entry: \" + entry.getName(), e);\n\t\t}\n\t}\n\n\tpublic InputStream getInputStream(FallbackZipEntry entry) {\n\t\ttry {\n\t\t\treturn getEntryStream(entry);\n\t\t} catch (Exception e) {\n\t\t\tthrow new RuntimeException(\"Failed to open input stream for entry: \" + entry.getName(), e);\n\t\t}\n\t}\n\n\tprivate InputStream getEntryStream(FallbackZipEntry entry) throws IOException {\n\t\tInputStream entryStream = zipFile.getInputStream(entry.getZipEntry());\n\t\tInputStream stream;\n\t\tif (useLimitedDataStream) {\n\t\t\tstream = new LimitedInputStream(entryStream, entry.getUncompressedSize());\n\t\t} else {\n\t\t\tstream = entryStream;\n\t\t}\n\t\treturn new BufferedInputStream(stream);\n\t}\n\n\tpublic File getZipFile() {\n\t\treturn file;\n\t}\n","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/skylot/jadx/blob/e738a26571d02919f01df40de93bc9a44dee4e18/jadx-commons/jadx-zip/src/main/java/jadx/zip/fallback/FallbackZipParser.java#L68-L104","documentation":"Thrown by the fallback parser when merely opening an InputStream for an entry fails, before any bytes are read. getInputStream() delegates to getEntryStream(), which calls ZipFile.getInputStream() and optionally wraps it in a LimitedInputStream. Unlike getBytes() (which consumes the stream fully), this error means the stream could not be opened at all. The failing entry name is included and the cause is preserved.","triggerScenarios":"Calling FallbackZipParser.getInputStream() (or IZipEntry.getInputStream() on a fallback entry) when ZipFile.getInputStream(entry) raises IOException because the entry's local header or data descriptor is malformed, the offset is out of range, or the entry was marked invalid after enumeration.","commonSituations":"Archive whose local file header offsets are inconsistent with the central directory; an entry referenced in the central directory but whose data is missing or truncated; zip produced by a buggy packer that jadx's fallback cannot stream; concurrent access where the ZipFile was already closed.","solutions":["Inspect getCause() to distinguish a closed-zip error from a structural entry error.","Ensure the ZipFile/ZipContent is not closed before all entry streams are consumed.","Skip the entry in a try/catch and continue processing the rest of the archive.","If every entry fails, the archive is structurally broken; obtain a fresh copy."],"exampleFix":"// before\ntry (InputStream is = entry.getInputStream()) {\n    return is.readAllBytes();\n}\n\n// after\ntry (InputStream is = entry.getInputStream()) {\n    return is.readAllBytes();\n} catch (RuntimeException e) {\n    throw new IOException(\"Cannot stream entry \" + entry.getName(), e.getCause());\n}","handlingStrategy":"try-catch","validationCode":"// No public 'isOpen()' probe exists; track zip lifecycle yourself.\n// Ensure the owning ZipContent/ZipFile is open before requesting streams:\nif (zipContent.isClosed()) {\n    throw new IllegalStateException(\"Zip closed before streaming entry\");\n}","typeGuard":null,"tryCatchPattern":"try (InputStream is = entry.getInputStream()) {\n    return is.readAllBytes();\n} catch (RuntimeException e) {\n    throw new IOException(\"Cannot stream entry \" + entry.getName(), e.getCause());\n}","preventionTips":["Do not close the ZipContent/ZipFile before consuming all entry streams.","Consume each entry stream fully before opening the next when possible.","For untrusted archives, catch and skip rather than abort the whole load."],"tags":["zip","io","fallback-parser","corrupted-archive"],"backgroundTag":null,"analyzedSha":"e738a26571d02919f01df40de93bc9a44dee4e18","analyzedAt":"2026-08-14T00:10:24.238Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}