{"record":{"id":"827701bbd9616cc1","repo":"apache/hadoop","slug":"eof-reached-file-size-is-and-more-bytes-lef","errorCode":null,"errorMessage":"EOF Reached. file size is {} and {} more bytes left to be transfered.","messagePattern":"EOF Reached\\. file size is (.+?) and (.+?) more bytes left to be transfered\\.","errorType":"exception","errorClass":"EOFException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/SocketOutputStream.java","lineNumber":227,"sourceCode":"       * Ideally we should wait after transferTo returns 0. But because of\n       * a bug in JRE on Linux (http://bugs.sun.com/view_bug.do?bug_id=5103988),\n       * which throws an exception instead of returning 0, we wait for the\n       * channel to be writable before writing to it. If you ever see \n       * IOException with message \"Resource temporarily unavailable\" \n       * thrown here, please let us know.\n       * \n       * Once we move to JAVA SE 7, wait should be moved to correct place.\n       */\n      long start = System.nanoTime();\n      waitForWritable();\n      long wait = System.nanoTime();\n\n      int nTransfered = (int) fileCh.transferTo(position, count, getChannel());\n      \n      if (nTransfered == 0) {\n        //check if end of file is reached.\n        if (position >= fileCh.size()) {\n          throw new EOFException(\"EOF Reached. file size is \" + fileCh.size() + \n                                 \" and \" + count + \" more bytes left to be \" +\n                                 \"transfered.\");\n        }\n        //otherwise assume the socket is full.\n        //waitForWritable(); // see comment above.\n      } else if (nTransfered < 0) {\n        throw new IOException(\"Unexpected return of \" + nTransfered + \n                              \" from transferTo()\");\n      } else {\n        position += nTransfered;\n        count -= nTransfered;\n      }\n      long transfer = System.nanoTime();\n      waitTime += wait - start;\n      transferTime += transfer - wait;\n    }\n    \n    if (waitForWritableTime != null) {","sourceCodeStart":209,"sourceCodeEnd":245,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/SocketOutputStream.java#L209-L245","documentation":"Error \"EOF Reached. file size is {} and {} more bytes left to be transfered.\" thrown in apache/hadoop.","triggerScenarios":"Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/SocketOutputStream.java:227 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the source file was not truncated or modified while being transferred; re-run the transfer against a stable file.","Check that the expected file size matches the actual bytes available on disk before starting transferTo.","Investigate disk or filesystem errors on the source node that may cause a premature EOF."],"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"}