private void checkForHashCodeChange ( Entry < K , V > e ) { K key = extractKeyObj ( e ) ; if ( extractIntKeyValue ( key , modifiedHash ( key . hashCode ( ) ) ) != e . hashCode ) { if ( keyMutationCnt == 0 ) { getLog ( ) . warn ( "Key mismatch! Key hashcode changed! keyClass=" + e . getKey ( ) . getClass ( ) . getName ( ) ) ; String s ; try { s = e . getKey ( ) . toString ( ) ; if ( s != null ) { getLog ( ) . warn ( "Key mismatch! key.toString(): " + s ) ; } } catch ( Throwable t ) { getLog ( ) . warn ( "Key mismatch! key.toString() threw exception" , t ) ; } } keyMutationCnt ++ ; } }
Check whether the key was modified during the stay of the entry in the cache . We only need to check this when the entry is removed since we expect that if the key has changed the stored hash code in the cache will not match any more and the item is evicted very fast .