Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getOldValue() consistently returns wrong results for entryUpdated listener notifications after replace() #418

Closed
ghost opened this issue Feb 7, 2013 · 1 comment

Comments

Projects
None yet
0 participants
@ghost
Copy link

commented Feb 7, 2013

Whenever I update a value using replace() rather than put(), the oldValue in the entryUpdated listener gives the samne thing as the new value, so there's no way to get the true old value. This happens consistently every time, on Hazelcast 2.5.

Here's some sample code:
IMap<Object, Object> map = instance.getMap("map");
map.addEntryListener(new EntryListener<Object, Object>() {

    @Override
    public void entryAdded(EntryEvent<Object, Object> event) {
    }


    @Override
    public void entryRemoved(EntryEvent<Object, Object> event) {
    }


    @Override
    public void entryUpdated(EntryEvent<Object, Object> event) {
        System.out.println("entryUpdated: old value:"+ event.getOldValue()+" -> new value: "+event.getValue());
        assert !event.getValue().equals(event.getOldValue());

    }


    @Override
    public void entryEvicted(EntryEvent<Object, Object> event) {
    }
}, true);


map.put("a",1);
map.put("a",2);

map.put("b",10);
map.replace("b",10,20);

Prints:
entryUpdated: old value:1 -> new value: 2
entryUpdated: old value:20 -> new value: 20

... showing that the old notification value is incorrect for replace() but correct for put()

@ghost

This comment has been minimized.

Copy link
Author

commented Apr 17, 2013

I'd appreciate it if someone could look into this issue - it's a serious and obvious correctness bug that's really hurting our ability to use hazelcast, and the above testcase reproduces it in a very simple and consistent way so it should be relative easy to tackle

Many thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.