{"record":{"id":"211b2bd5c43422c6","repo":"pentaho/pentaho-kettle","slug":"unable-to-close-file-channel-for-file","errorCode":null,"errorMessage":"Unable to close file channel for file '","messagePattern":"Unable to close file channel for file '","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"warning","filePath":"plugins/s3csvinput/core/src/main/java/org/pentaho/di/trans/steps/s3csvinput/S3CsvInput.java","lineNumber":608,"sourceCode":"          data.totalFileSize = 0L;\n        }\n\n        return true;\n      } catch ( Exception e ) {\n        logError( \"Unexpected error trying to verify S3 settings : \", e );\n      }\n\n    }\n    return false;\n  }\n\n  public void closeFile() throws KettleException {\n    try {\n      if ( data.s3ObjectInputStream != null ) {\n        data.s3ObjectInputStream.close();\n      }\n    } catch ( IOException e ) {\n      throw new KettleException( \"Unable to close file channel for file '\" + data.filenames[data.filenr - 1], e );\n    }\n  }\n}\n","sourceCodeStart":590,"sourceCodeEnd":612,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/s3csvinput/core/src/main/java/org/pentaho/di/trans/steps/s3csvinput/S3CsvInput.java#L590-L612","documentation":"closeFile closes the S3 object input stream after reading. If stream.close() throws an IOException, it is rethrown as a KettleException with the literal message 'Unable to close file channel for file ' plus the last-processed filename. It is a cleanup failure after reading, not a data error.","triggerScenarios":"Calling closeFile (at end of file or step termination) when the S3ObjectInputStream close fails — e.g. connection abort during abort/drain, stream already abnormally terminated, or SDK close-time validation failing.","commonSituations":"Cancelling/stopping a transformation mid-file; S3 network blips at end of large reads; SDK aborting a partially consumed stream.","solutions":["Check the wrapped IOException cause; if the data was fully read, treat as a non-fatal cleanup warning","Ensure the stream is fully consumed or explicitly aborted before close (SDK abort() instead of relying on close for partial reads)","Verify network stability / proxy keep-alive settings","Upgrade the S3 SDK for more robust abort/close semantics"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if ( data.s3ObjectInputStream != null ) { /* ensure fully read or abort()ed */ }","typeGuard":null,"tryCatchPattern":"try {\n  closeFile();\n} catch ( KettleException e ) {\n  logBasic( \"Non-fatal close failure on \" + e.getMessage() ); // data already processed\n}","preventionTips":["Consume or abort() the stream instead of relying on close for partial reads","Do not stop transformations mid-file when avoidable","Maintain stable network/keep-alive settings","Update the AWS SDK for robust stream abort semantics"],"tags":["s3","io","stream-close","cleanup"],"backgroundTag":"file-close-failed","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"}