Skip to content

Commit

Permalink
JCache Cache.invoke does not update entry after initial load (fixes #210
Browse files Browse the repository at this point in the history
)
  • Loading branch information
ben-manes committed Dec 26, 2017
1 parent 4c670e5 commit 78e97fc
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,15 @@
* @author [email protected] (Ben Manes)
*/
public final class EntryProcessorEntry<K, V> implements MutableEntry<K, V> {
private final boolean hasEntry;
private final K key;

private V value;
private Action action;
private Optional<CacheLoader<K, V>> cacheLoader;

public EntryProcessorEntry(K key, @Nullable V value, Optional<CacheLoader<K, V>> cacheLoader) {
this.hasEntry = (value != null);
this.cacheLoader = cacheLoader;
this.action = Action.NONE;
this.value = value;
Expand Down Expand Up @@ -81,8 +83,8 @@ public void remove() {
@Override
public void setValue(V value) {
requireNonNull(value);
if ((action != Action.CREATED) && (action != Action.LOADED)) {
action = exists() ? Action.UPDATED : Action.CREATED;
if (action != Action.CREATED) {
action = (exists() && hasEntry) ? Action.UPDATED : Action.CREATED;
}
this.value = value;
}
Expand Down

0 comments on commit 78e97fc

Please sign in to comment.