{"record":{"id":"b36c0ffc3c5b83f2","repo":"apache/hadoop","slug":"unexpected-return-of-from-transferto","errorCode":null,"errorMessage":"Unexpected return of {} from transferTo()","messagePattern":"Unexpected return of (.+?) from transferTo\\(\\)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/SocketOutputStream.java","lineNumber":234,"sourceCode":"       * 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) {\n      waitForWritableTime.set(waitTime);\n    }\n    if (transferToTime != null) {\n      transferToTime.set(transferTime);\n    }\n  }\n","sourceCodeStart":216,"sourceCodeEnd":252,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/SocketOutputStream.java#L216-L252","documentation":"Error \"Unexpected return of {} from transferTo()\" thrown in apache/hadoop.","triggerScenarios":"Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/SocketOutputStream.java:234 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the underlying FileChannel and filesystem for errors; transferTo returning an unexpected count usually indicates an I/O problem or concurrent modification of the file.","Verify the file size did not change during the transfer and retry the operation.","Review OS-level limits (sendfile limits) and fall back to stream-based copy if zero-copy transfer is unreliable on this platform."],"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"}