private void testRecoveryWithBadMessageSize(List<Record> records, int size) throws IOException { LogSegment seg = this.store.log().lastSegment(); writeToOffset(seg.file(), seg.file().length(), ByteBuffer.allocate(4).putInt(size).array()); // now add some message bytes, but not enough if (size > 0) writeToOffset( seg.file(), seg.file().length(), ByteBuffer.allocate(Math.min(size - 1, 256)).array()); this.store.close(); this.store = new HashStore(config); assertEquals("Same records should be present after close and re-open", records, records(store)); }