{"record":{"id":"da257427eb06d525","repo":"pentaho/pentaho-kettle","slug":"end-of-file-reached-dbcacheentry","errorCode":null,"errorMessage":"End of file reached","messagePattern":"End of file reached","errorType":"exception","errorClass":"KettleEOFException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/core/DBCacheEntry.java","lineNumber":98,"sourceCode":"    }\n    return false;\n  }\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;","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/core/DBCacheEntry.java#L80-L116","documentation":"Thrown by the DBCacheEntry(DataInputStream) constructor when the stream ends before the database name and SQL strings have been fully read. The library wraps the low-level EOFException in a KettleEOFException to signal that the cached database-query entry is truncated.","triggerScenarios":"Calling new DBCacheEntry(dis) on a DataInputStream whose content is shorter than two UTF strings — e.g. the underlying DBCache file was truncated by a crash, partial copy, or disk-full while the cache file was being written.","commonSituations":"A corrupted or half-written kettle.properties-adjacent DBCache file after a JVM kill, a manually truncated cache file, deserializing a stream positioned at the wrong offset, or reading a cache file from a different PDI version.","solutions":["Delete the corrupt DBCache file (typically $KETTLE_HOME/.kettle/db.cache) and let Pentaho rebuild it","Verify the cache file was fully written/transferred (compare sizes or checksums against a healthy install)","Check that the stream being passed actually points at the start of a DBCacheEntry and was produced by DBCacheEntry.write","Wrap the constructor call so KettleEOFException clears/rebuilds the cache instead of aborting"],"exampleFix":"// before\nDBCacheEntry entry = new DBCacheEntry(dis);\n// after\nDBCacheEntry entry;\ntry {\n  entry = new DBCacheEntry(dis);\n} catch (KettleEOFException e) {\n  cache.clear(); // truncated/corrupt cache file\n  entry = null;\n}","handlingStrategy":"try-catch","validationCode":"// verify cache file exists and is plausibly sized before reading\nFile cacheFile = new File(System.getProperty(\"user.home\"), \".kettle/db.cache\");\nif (!cacheFile.exists() || cacheFile.length() < 8) {\n  cacheFile.delete(); // force rebuild\n}","typeGuard":null,"tryCatchPattern":"try {\n  DBCacheEntry entry = new DBCacheEntry(dis);\n} catch (KettleEOFException e) {\n  // treat cache as corrupt: clear cache and continue without cache\n}","preventionTips":["Never manually truncate or hand-edit the db.cache file","Shut down Kettle processes cleanly so cache writes complete","Catch KettleEOFException at cache-load time and rebuild rather than propagating"],"tags":["io","serialization","eof","cache"],"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"}