Source:
<code>public ResolvedChain<K, V> resolve(Chain chain, K key, long now) { Result<V> result = null; ChainBuilder chainBuilder = new ChainBuilder(); Operation<K, V> operation = null; boolean isNew = false; for (Element element : chain) { ByteBuffer payload = element.getPayload(); operation = codec.decode(payload); final Result<V> previousResult = result; Duration expiration; if(key.equals(operation.getKey())) { result = operation.apply(result); if(result == null) { continue; } if((previousResult == null & operation.isFirst())) { expiration = expiry.getExpiryForCreation(key, result.getValue()); isNew = true; } else { expiration = expiry.getExpiryForUpdate(key, new ValueSupplier<V>() { @Override public V value() { return previousResult != null ? previousResult.getValue() : null; } }, result.getValue()); <START> } <END> if(expiration == null || expiration.isInfinite()) { continue; } long time = TIME_UNIT.convert(expiration.getLength(), expiration.getTimeUnit()); if(now >= time + operation.timeStamp()) { result = null; } } else { payload.flip(); chainBuilder = chainBuilder.add(payload); } } Operation<K, V> resolvedOperation = null; if(result != null & operation != null) { resolvedOperation = new PutOperation<K, V>(key, result.getValue(), operation.timeStamp(), isNew); ByteBuffer payload = codec.encode(resolvedOperation); chainBuilder = chainBuilder.add(payload); } return new ResolvedChain.Impl<K, V>(chainBuilder.build(), key, result); }</code><technical_language>forgot set _isNew_ flag _false_ in this else block. in else block want change flag if current entry is gonna get expired in subsequent steps. in I feel set _false_ "somewhere" is missing. Please correct if wrong</technical_language>

Target:
public ResolvedChain<K, V> resolve(Chain chain, K key, long now) { Result<V> result = null; ChainBuilder chainBuilder = new ChainBuilder(); long expirationTime = Long.MIN_VALUE; for (Element element : chain) { ByteBuffer payload = element.getPayload(); Operation<K, V> operation = codec.decode(payload); final Result<V> previousResult = result; if(key.equals(operation.getKey())) { result = operation.apply(result); if(result == null) { continue; } if(operation.isExpiryAvailable()) { expirationTime = operation.expirationTime(); if (expirationTime == Long.MIN_VALUE) { continue; } if (now >= expirationTime) { result = null; } } else { Duration duration; try { if(previousResult == null) { duration = expiry.getExpiryForCreation(key, result.getValue()); if (duration == null) { result = null; continue; } } else { duration = expiry.getExpiryForUpdate(key, new ValueSupplier<V>() { @Override public V value() { return previousResult.getValue(); } }, result.getValue()); if (duration == null) { continue; } } } catch (Exception ex) { LOG.error("Expiry computation caused an exception - Expiry duration will be 0 ", ex); duration = Duration.ZERO; } if(duration.isInfinite()) { expirationTime = Long.MIN_VALUE; continue; } long time = TIME_UNIT.convert(duration.getLength(), duration.getTimeUnit()); expirationTime = time + operation.timeStamp(); if(now >= expirationTime) { result = null; } } } else { payload.flip(); chainBuilder = chainBuilder.add(payload); } } if(result != null) { Operation<K, V> resolvedOperation = new PutOperation<K, V>(key, result.getValue(), -expirationTime); ByteBuffer payload = codec.encode(resolvedOperation); chainBuilder = chainBuilder.add(payload); } return new ResolvedChain.Impl<K, V>(chainBuilder.build(), key, result); }