Source:
private void readCleanupTokenAndPopulateRecoveryRange() throws IOException, StoreException { File cleanupTokenFile = new File(dataDir, Cleanup_Token_Filename); recoveryStartToken = recoveryEndToken = new StoreFindToken(); startToken = startTokenBeforeLogFlush = startTokenSafeToPersist = endToken = new StoreFindToken(); if (cleanupTokenFile.exists()) { CrcInputStream crcStream = new CrcInputStream(new FileInputStream(cleanupTokenFile)); DataInputStream stream = new DataInputStream(crcStream); try { short version = stream.readShort(); switch (version) { case 0: recoveryStartToken = StoreFindToken.fromBytes(stream, factory); recoveryEndToken = StoreFindToken.fromBytes(stream, factory); int numBlobsToRecover = stream.readInt(); for (int i = 0; i < numBlobsToRecover; i++) { BlobReadOptions blobReadOptions = BlobReadOptions.fromBytes(stream, factory); byte[] messageStoreRecoveryInfo = hardDelete.processAndReturnRecoveryInfo(stream, blobReadOptions.getStoreKey()); hardDeleteRecoveryRange.add(new HardDeletePersistInfo(blobReadOptions, messageStoreRecoveryInfo)); } break; default: throw new StoreException("Invalid version in cleanup token " + dataDir, StoreErrorCodes.Index_Version_Error); } long crc = crcStream.getValue(); if (crc != stream.readLong()) { hardDeleteRecoveryRange.clear(); metrics.hardDeleteIncompleteRecoveryCount.inc(); throw new StoreException( "Crc check does not match for cleanup token file for dataDir " + dataDir + " creating a clean one ", StoreErrorCodes.Illegal_Index_State); } } catch (IOException e) { throw new StoreException("Failed to read cleanup token ", e, StoreErrorCodes.Initialization_Error); } finally { stream.close(); } } startToken = startTokenBeforeLogFlush = startTokenSafeToPersist = endToken = recoveryStartToken; }

Target:
private void readCleanupTokenAndPopulateRecoveryRange() throws IOException, StoreException { File cleanupTokenFile = new File(dataDir, Cleanup_Token_Filename); recoveryStartToken = recoveryEndToken = new StoreFindToken(); startToken = startTokenBeforeLogFlush = startTokenSafeToPersist = endToken = new StoreFindToken(); if (cleanupTokenFile.exists()) { CrcInputStream crcStream = new CrcInputStream(new FileInputStream(cleanupTokenFile)); DataInputStream stream = new DataInputStream(crcStream); try { short version = stream.readShort(); switch (version) { case Cleanup_Token_Version_V1: recoveryStartToken = StoreFindToken.fromBytes(stream, factory); recoveryEndToken = StoreFindToken.fromBytes(stream, factory); hardDeleteRecoveryRange = new HardDeletePersistInfo(stream, factory); break; default: hardDeleteRecoveryRange.clear(); metrics.hardDeleteIncompleteRecoveryCount.inc(); throw new StoreException("Invalid version in cleanup token " + dataDir, StoreErrorCodes.Index_Version_Error); } long crc = crcStream.getValue(); if (crc != stream.readLong()) { hardDeleteRecoveryRange.clear(); metrics.hardDeleteIncompleteRecoveryCount.inc(); throw new StoreException( "Crc check does not match for cleanup token file for dataDir " + dataDir + " aborting. ", StoreErrorCodes.Illegal_Index_State); } } catch (IOException e) { hardDeleteRecoveryRange.clear(); metrics.hardDeleteIncompleteRecoveryCount.inc(); throw new StoreException("Failed to read cleanup token ", e, StoreErrorCodes.Initialization_Error); } finally { stream.close(); } } startToken = startTokenBeforeLogFlush = startTokenSafeToPersist = endToken = recoveryStartToken; }