{"record":{"id":"b0cfbc4755053001","repo":"apache/seatunnel","slug":"null-inputstream","errorCode":null,"errorMessage":"Null InputStream","messagePattern":"Null InputStream","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-file/connector-file-sftp/src/main/java/org/apache/seatunnel/connectors/seatunnel/file/sftp/system/SFTPInputStream.java","lineNumber":51,"sourceCode":"    public static final String E_NULL_INPUT_STREAM = \"Null InputStream\";\n    public static final String E_STREAM_CLOSED = \"Stream closed\";\n    public static final String E_CLIENT_NOT_CONNECTED = \"Client not connected\";\n\n    private InputStream wrappedStream;\n    private ChannelSftp channel;\n    private SFTPConnectionPool connectionPool;\n    private FileSystem.Statistics stats;\n    private boolean closed;\n    private long pos;\n\n    SFTPInputStream(\n            InputStream stream,\n            ChannelSftp channel,\n            SFTPConnectionPool connectionPool,\n            FileSystem.Statistics stats) {\n\n        if (stream == null) {\n            throw new IllegalArgumentException(E_NULL_INPUT_STREAM);\n        }\n        if (channel == null || !channel.isConnected()) {\n            throw new IllegalArgumentException(E_CLIENT_NULL);\n        }\n        this.wrappedStream = stream;\n        this.channel = channel;\n        this.connectionPool = connectionPool;\n        this.stats = stats;\n\n        this.pos = 0;\n        this.closed = false;\n    }\n\n    @Override\n    public void seek(long position) throws IOException {\n        throw new IOException(E_SEEK_NOT_SUPPORTED);\n    }\n","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-file/connector-file-sftp/src/main/java/org/apache/seatunnel/connectors/seatunnel/file/sftp/system/SFTPInputStream.java#L33-L69","documentation":"The SFTPInputStream constructor validates its arguments and throws IllegalArgumentException when the wrapped InputStream is null. This guards against constructing a stream object that would fail later on first read, surfacing the mistake at creation time instead.","triggerScenarios":"Calling SFTPInputStream.getInstance(...) or the constructor when the SFTP get/open call returned null instead of a stream — e.g. the remote open silently failed or a caller passed a null stream.","commonSituations":"SFTP server returning a null stream on get due to an unreported error; programmatic misuse of the constructor with a failed get() result not checked for null.","solutions":["Check the code path that produced the null InputStream — re-open the remote file and verify get() succeeded.","Verify the remote file exists and is readable before opening the stream (getFileStatus).","If using the constructor directly, never pass an unchecked get() result; handle failure before construction.","Retry the open; if it persists, check SFTP server logs for the failed open."],"exampleFix":"// before\nInputStream in = channel.get(path); // may be null on failure\nSFTPInputStream s = new SFTPInputStream(in, channel, pool, stats);\n// after\nInputStream in = channel.get(path);\nif (in == null) { throw new IOException(\"SFTP get returned null for \" + path); }\nSFTPInputStream s = new SFTPInputStream(in, channel, pool, stats);","handlingStrategy":"validation","validationCode":"InputStream in = channel.get(path);\nif (in == null) { throw new IOException(\"SFTP get failed (null stream) for \" + path); }","typeGuard":"if (stream != null) { new SFTPInputStream(stream, channel, pool, stats); }","tryCatchPattern":"try { in = SFTPInputStream.getInstance(path, ...); }\ncatch (IllegalArgumentException e) { /* null stream: re-open with verified file */ }","preventionTips":["Check file existence/readability before opening streams","Never pass unchecked channel.get() results directly to the constructor","Log and retry opens that return null"],"tags":["sftp","inputstream","null-argument","illegalargument"],"backgroundTag":"null-argument","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}