{"record":{"id":"c0e11ee58050a4ea","repo":"pentaho/pentaho-kettle","slug":"not-a-valid-input-stream","errorCode":null,"errorMessage":"Not a valid input stream!","messagePattern":"Not a valid input stream!","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/core/compress/zip/ZIPCompressionInputStream.java","lineNumber":45,"sourceCode":"  public ZIPCompressionInputStream( InputStream in, CompressionProvider provider ) {\n    super( getDelegate( in ), provider );\n  }\n\n  protected static ZipInputStream getDelegate( InputStream in ) {\n    ZipInputStream delegate;\n    if ( in instanceof ZipInputStream ) {\n      delegate = (ZipInputStream) in;\n    } else {\n      delegate = new ZipInputStream( in );\n    }\n    return delegate;\n  }\n\n  @Override\n  public void close() throws IOException {\n    ZipInputStream zis = (ZipInputStream) delegate;\n    if ( zis == null ) {\n      throw new IOException( INVALID_INPUT_MSG );\n    }\n    zis.close();\n  }\n\n  @Override\n  public int read() throws IOException {\n    ZipInputStream zis = (ZipInputStream) delegate;\n    if ( zis == null ) {\n      throw new IOException( INVALID_INPUT_MSG );\n    }\n    return zis.read();\n  }\n\n  @Override\n  public Object nextEntry() throws IOException {\n    ZipInputStream zis = (ZipInputStream) delegate;\n    if ( zis == null ) {\n      throw new IOException( INVALID_INPUT_MSG );","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/core/compress/zip/ZIPCompressionInputStream.java#L27-L63","documentation":"ZIPCompressionInputStream.close() casts its delegate to ZipInputStream and throws IOException('Not a valid input stream!') when the delegate is null. In practice the guard means the stream was constructed incorrectly or the delegate field was never assigned — the code can only close a real ZipInputStream.","triggerScenarios":"Calling close() on a ZIPCompressionInputStream whose protected 'delegate' field is null — i.e. the object was created without a valid ZipInputStream (bad/empty underlying stream during construction, or a subclass that never set delegate).","commonSituations":"CompressionInputStreamFactory created a ZIP input on a corrupt/empty zip source causing delegate to be null; custom subclasses overriding setup; closing an already-aborted stream after a failed constructor.","solutions":["Check the IOException thrown at construction time; if the underlying zip file is empty or invalid, fix the source file before reading.","Ensure code never keeps/uses a stream instance whose constructor failed — the delegate will be null.","If writing a subclass, always assign the delegate ZipInputStream before use.","Guard the close call yourself: check the stream opened successfully before closing."],"exampleFix":"// before\nZIPCompressionInputStream in = new ZIPCompressionInputStream(fis); // ctor failed, delegate null\nin.close(); // IOException: Not a valid input stream!\n// after\nZIPCompressionInputStream in = null;\ntry {\n  in = new ZIPCompressionInputStream(fis);\n  ...\n} catch (IOException e) {\n  // construction failed; do not close\n} finally {\n  if (in != null) in.close();\n}","handlingStrategy":"try-catch","validationCode":"if (zipFile == null || zipFile.length() == 0) {\n  throw new IllegalArgumentException(\"ZIP source is empty or missing\");\n}","typeGuard":null,"tryCatchPattern":"try (ZIPCompressionInputStream in = new ZIPCompressionInputStream(fis)) { ... } catch (IOException e) { if (\"Not a valid input stream!\".equals(e.getMessage())) logError(\"Stream never opened properly\"); }","preventionTips":["Never reuse/close a stream whose constructor threw IOException","Validate the zip file exists and is non-empty before opening","When subclassing, always assign the delegate field"],"tags":["zip","io","stream"],"backgroundTag":"null-argument","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}