{"record":{"id":"08ff17604c2a72bd","repo":"pentaho/pentaho-kettle","slug":"exception-reading-line-using-nio","errorCode":null,"errorMessage":"Exception reading line using NIO","messagePattern":"Exception reading line using NIO","errorType":"exception","errorClass":"KettleFileException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/csvinput/CsvInput.java","lineNumber":860,"sourceCode":"      }\n\n      if ( !ignoreEnclosures ) {\n        incrementLinesInput();\n      }\n\n      if ( conversionExceptions != null && conversionExceptions.size() > 0 ) {\n        // Forward the first exception\n        //\n        throw new KettleConversionException(\n          \"There were \" + conversionExceptions.size() + \" conversion errors on line \" + getLinesInput(),\n          conversionExceptions, exceptionFields, outputRowData );\n      }\n\n      return outputRowData;\n    } catch ( KettleConversionException e ) {\n      throw e;\n    } catch ( IOException e ) {\n      throw new KettleFileException( \"Exception reading line using NIO\", e );\n    }\n  }\n\n\n  public boolean init( StepMetaInterface smi, StepDataInterface sdi ) {\n    meta = (CsvInputMeta) smi;\n    data = (CsvInputData) sdi;\n\n    if ( super.init( smi, sdi ) ) {\n      // PDI-10242 see if a variable is used as encoding value\n      String realEncoding = environmentSubstitute( meta.getEncoding() );\n      data.preferredBufferSize = Integer.parseInt( environmentSubstitute( meta.getBufferSize() ) );\n\n      // If the step doesn't have any previous steps, we just get the filename.\n      // Otherwise, we'll grab the list of file names later...\n      //\n      if ( getTransMeta().findNrPrevSteps( getStepMeta() ) == 0 ) {\n","sourceCodeStart":842,"sourceCodeEnd":878,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/csvinput/CsvInput.java#L842-L878","documentation":"readOneRow catches KettleConversionException (rethrown as-is) and any IOException, wrapping it in a KettleFileException with the fixed message 'Exception reading line using NIO'. This indicates a low-level I/O failure while reading/decoding bytes from the memory-mapped/channel buffer during row parsing, not a data conversion problem.","triggerScenarios":"IOException thrown during buffer reads in readOneRow: file truncated/changed while being read, disk I/O error, or decode errors surfacing as IOException from the NIO channel path in outputRowData or openNextFile.","commonSituations":"File being overwritten or rotated while the transformation reads it; disk errors; reading a file on an unstable network mount (mapped locally); antivirus locking the file mid-read.","solutions":["Check the cause chain of the KettleFileException for the real IOException and address it (disk, permissions, truncation).","Ensure no other process rewrites/deletes the file during the run; copy to a staging location first.","Re-run the transformation to rule out a transient I/O error.","If reading from a network drive, copy the file locally before processing."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// ensure the file is stable and readable before reading rows\njava.io.File f = new java.io.File(filename);\nif (!f.canRead() || !f.isFile()) throw new IllegalStateException(\"Unreadable: \" + filename);","typeGuard":null,"tryCatchPattern":"try { ... } catch (KettleFileException e) {\n  logError(\"NIO read failure on CSV line; cause=\" + e.getCause(), e);\n  setErrors(1);\n}","preventionTips":["Copy files to local disk before processing instead of reading from network mounts","Avoid writing/rotating the file while the transformation reads it","Exclude data directories from antivirus scanning during runs","Check the cause chain for the real IOException"],"tags":["kettle","pentaho","nio","io-exception"],"backgroundTag":"file-read-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"}