Skip to content
This repository has been archived by the owner on Oct 3, 2022. It is now read-only.

Updating cache with EntryProcessor does not update #37

Closed
tarioch opened this issue Dec 8, 2014 · 2 comments
Closed

Updating cache with EntryProcessor does not update #37

tarioch opened this issue Dec 8, 2014 · 2 comments
Assignees
Labels
Milestone

Comments

@tarioch
Copy link

tarioch commented Dec 8, 2014

I use a cache configured with

copyOnRead="true"
copyOnWrite="true"

In the processor the code looks more or less like this:

Value value = entry.getValue();
value.modifySomehow();
entry.setValue(value);

after this, the cache remains unchanged.

Looking at the code it's easy to see why

in JCache, line 884

        void apply(final JCache<K, V> jCache) {
            if(deleted && !skipDelete) {
                jCache.remove(key);
            }
            if(newValue != initialValue && newValue != null) {
                jCache.put(key, newValue);
            }
        }

So in my case newValue == initialValue but it should still do a put as the value was modified. Maybe if it's using copyOnRead/copyOnWrite it should always put the value? Or is there something I missed/another way I can force an update (besides actually creating a new Value object which I'd rather not do).

@alexsnaps alexsnaps added the Bug label Dec 9, 2014
@alexsnaps alexsnaps self-assigned this Dec 9, 2014
@alexsnaps alexsnaps added this to the 1.0.2 milestone Dec 9, 2014
@alexsnaps
Copy link
Member

Hey Patrick,
This is indeed a bug, the implementation should reput as soon as .setValue was invoked indeed.
I'll work on fixing this... Thanks for report this!
Alex

alexsnaps added a commit to alexsnaps/ehcache-jcache that referenced this issue Dec 9, 2014
@alexsnaps
Copy link
Member

@ljacomet Can you have a look at this failure? Confused why the maven build could be broken by this changeset here...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants