Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.fasterxml.clustermate.service.store;
 
 
 public class AllowUndeletingUpdates implements OverwriteChecker
 {
    public final static OverwriteChecker instance = new AllowUndeletingUpdates();
    // Nope, can't say without seeing entries in question
    @Override
    public Boolean mayOverwrite(StorableKey key) { return null; }

    
Logic for overwrite are such that we may overwrite (soft) deleted entries, as long as hash codes are compatible
    @Override
    public boolean mayOverwrite(StorableKey keyStorable oldEntryStorable newEntry)
    {
        return oldEntry.isDeleted()
                && _hashCodesMatch(oldEntry.getContentHash(), newEntry.getContentHash())
                && _hashCodesMatch(oldEntry.getCompressedHash(), newEntry.getCompressedHash())
                ;
    }
    protected boolean _hashCodesMatch(int hash1int hash2) {
        // if either one is missing, need to accept
        if (hash1 == . || hash2 == .) {
            return true;
        }
        return (hash1 == hash2);
    }
New to GrepCode? Check out our FAQ X