{"record":{"id":"19e4464a034d4946","repo":"pentaho/pentaho-kettle","slug":"unable-to-read-cache-entry-from-data-input-stream","errorCode":null,"errorMessage":"Unable to read cache entry from data input stream","messagePattern":"Unable to read cache entry from data input stream","errorType":"exception","errorClass":"KettleFileException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/core/DBCacheEntry.java","lineNumber":100,"sourceCode":"  }\n\n  /**\n   * Read the data for this Cache entry from a data input stream\n   *\n   * @param dis\n   *          The DataInputStream to read this entry from.\n   * @throws KettleFileException\n   *           if the cache can't be read from disk when it should be able to. If the cache file doesn't exists, no\n   *           exception is thrown\n   */\n  public DBCacheEntry( DataInputStream dis ) throws KettleFileException {\n    try {\n      dbname = dis.readUTF();\n      sql = dis.readUTF();\n    } catch ( EOFException eof ) {\n      throw new KettleEOFException( \"End of file reached\", eof );\n    } catch ( Exception e ) {\n      throw new KettleFileException( \"Unable to read cache entry from data input stream\", e );\n    }\n  }\n\n  /**\n   * Write the data for this Cache entry to a data output stream\n   *\n   * @param dos\n   *          The DataOutputStream to write this entry to.\n   * @return True if all went well, false if an error occured!\n   */\n  public boolean write( DataOutputStream dos ) {\n    try {\n      dos.writeUTF( dbname );\n      dos.writeUTF( sql );\n\n      return true;\n    } catch ( Exception e ) {\n      return false;","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/core/DBCacheEntry.java#L82-L118","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Confirm the input stream reads from a valid DBCache file produced by DBCacheEntry.write, not another file type","Delete the corrupt cache file and let it regenerate","Ensure no other code has consumed bytes from the stream before the constructor runs (offset misalignment)","Catch KettleFileException around the call and skip/rebuild the cache entry"],"exampleFix":"// before\nDBCacheEntry entry = new DBCacheEntry(dis);\n// after\ntry {\n  DBCacheEntry entry = new DBCacheEntry(dis);\n} catch (KettleFileException e) {\n  log.warn(\"Invalid cache entry skipped, rebuilding\", e);\n  entry = null;\n}","handlingStrategy":"try-catch","validationCode":"File cacheFile = new File(\"db.cache\");\nif (cacheFile.length() == 0) {\n  cacheFile.delete();\n  return; // nothing to read\n}","typeGuard":null,"tryCatchPattern":"try {\n  DBCacheEntry entry = new DBCacheEntry(dis);\n} catch (KettleFileException e) {\n  log.warn(\"Skipping unreadable cache entry\", e);\n}","preventionTips":["Only feed streams produced by DBCacheEntry.write into the constructor","Keep stream position at the entry start; don't share the stream across unrelated reads","Delete cache files when upgrading PDI versions"],"tags":["io","serialization","cache","corrupt-data"],"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"}