pentaho/pentaho-kettle · error · KettleFileException

Unable to read cache entry from data input stream

Error message

Unable to read cache entry from data input stream

What it means

Thrown by the DBCacheEntry(DataInputStream) constructor when any non-EOF error occurs while reading the dbname/sql UTF strings — e.g. corrupted UTF data, wrong stream format, or an underlying IOException. It signals the stream does not contain a valid cache entry.

Solutions

  1. Confirm the input stream reads from a valid DBCache file produced by DBCacheEntry.write, not another file type
  2. Delete the corrupt cache file and let it regenerate
  3. Ensure no other code has consumed bytes from the stream before the constructor runs (offset misalignment)
  4. Catch KettleFileException around the call and skip/rebuild the cache entry

Example fix

// before
DBCacheEntry entry = new DBCacheEntry(dis);
// after
try {
  DBCacheEntry entry = new DBCacheEntry(dis);
} catch (KettleFileException e) {
  log.warn("Invalid cache entry skipped, rebuilding", e);
  entry = null;
}
Defensive patterns

Strategy: try-catch

Validate before calling

File cacheFile = new File("db.cache");
if (cacheFile.length() == 0) {
  cacheFile.delete();
  return; // nothing to read
}

Try / catch

try {
  DBCacheEntry entry = new DBCacheEntry(dis);
} catch (KettleFileException e) {
  log.warn("Skipping unreadable cache entry", e);
}

Prevention

When it happens

Trigger: Calling new DBCacheEntry(dis) on a stream whose bytes are not a DBCacheEntry serialization: wrong file type passed in, stream offset misaligned, or DataInputStream.readUTF() hitting malformed modified-UTF-8 bytes.

Common situations: Pointing the deserializer at a random/config file instead of the db.cache file, reading a cache file created by an incompatible PDI version, mixing byte streams with reader streams so offsets shift.

Understand the failure class

Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.

Related errors


AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13). Data as JSON: /api/errors/19e4464a034d4946. Report an issue: GitHub.

Appendix: source

Thrown at core/src/main/java/org/pentaho/di/core/DBCacheEntry.java:100

  }

  /**
   * Read the data for this Cache entry from a data input stream
   *
   * @param dis
   *          The DataInputStream to read this entry from.
   * @throws KettleFileException
   *           if the cache can't be read from disk when it should be able to. If the cache file doesn't exists, no
   *           exception is thrown
   */
  public DBCacheEntry( DataInputStream dis ) throws KettleFileException {
    try {
      dbname = dis.readUTF();
      sql = dis.readUTF();
    } catch ( EOFException eof ) {
      throw new KettleEOFException( "End of file reached", eof );
    } catch ( Exception e ) {
      throw new KettleFileException( "Unable to read cache entry from data input stream", e );
    }
  }

  /**
   * Write the data for this Cache entry to a data output stream
   *
   * @param dos
   *          The DataOutputStream to write this entry to.
   * @return True if all went well, false if an error occured!
   */
  public boolean write( DataOutputStream dos ) {
    try {
      dos.writeUTF( dbname );
      dos.writeUTF( sql );

      return true;
    } catch ( Exception e ) {
      return false;

View on GitHub (pinned to f3058517a1)