{"record":{"id":"b8f35e7d9f89a13d","repo":"apache/hadoop","slug":"could-not-read-from-stream","errorCode":null,"errorMessage":"Could not read from stream","messagePattern":"Could not read from stream","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/SocketInputStream.java","lineNumber":124,"sourceCode":"   * @throws IOException raised on errors performing I/O.\n   */\n  public SocketInputStream(Socket socket) throws IOException {\n    this(socket.getChannel(), socket.getSoTimeout());\n  }\n  \n  @Override\n  public int read() throws IOException {\n    /* Allocation can be removed if required.\n     * probably no need to optimize or encourage single byte read.\n     */\n    byte[] buf = new byte[1];\n    int ret = read(buf, 0, 1);\n    if (ret > 0) {\n      return (int)(buf[0] & 0xff);\n    }\n    if (ret != -1) {\n      // unexpected\n      throw new IOException(\"Could not read from stream\");\n    }\n    return ret;\n  }\n\n  @Override\n  public int read(byte[] b, int off, int len) throws IOException {\n    return read(ByteBuffer.wrap(b, off, len));\n  }\n\n  @Override\n  public synchronized void close() throws IOException {\n    /* close the channel since Socket.getInputStream().close()\n     * closes the socket.\n     */\n    reader.channel.close();\n    reader.close();\n  }\n","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/SocketInputStream.java#L106-L142","documentation":"Error \"Could not read from stream\" thrown in apache/hadoop.","triggerScenarios":"Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/SocketInputStream.java:124 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check that the remote peer did not close the connection prematurely; retry the read or reconnect the socket.","Verify network stability between client and server and inspect server logs for errors that caused it to close the stream.","Increase the socket timeout (e.g. dfs.socket.timeout) if the read fails under heavy load."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}