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

Entry Listener is not aware of intercepted map value #7991

Closed
GhostInAMachine opened this issue Apr 20, 2016 · 1 comment

Comments

Projects
None yet
2 participants
@GhostInAMachine
Copy link

commented Apr 20, 2016

If you setup an interceptor to change the data being inserted the entry listeners are still firing with the old value.

Test case:

In the program below one would expect that the listener will print "foo" instead of "bar"

package playground;

import com.hazelcast.config.Config;
import com.hazelcast.config.EntryListenerConfig;
import com.hazelcast.config.MapConfig;
import com.hazelcast.core.*;
import com.hazelcast.map.MapInterceptor;

public class InterceptorBug {

    public static final String MAP = "map";

    public static void main(String[] args) {
        Config config = new Config();
        MapConfig mapConfig = config.getMapConfig(MAP);
        mapConfig.addEntryListenerConfig(new EntryListenerConfig("playground.InterceptorBug$Listener", true, true));
        HazelcastInstance hazelcastInstance = Hazelcast.newHazelcastInstance(config);
        IMap<String, String> map = hazelcastInstance.getMap(MAP);
        map.addInterceptor(new Interceptor());
        map.put("1", "bar");
    }

    public static class Listener extends EntryAdapter<String, String> {
        @Override
        public void entryAdded(EntryEvent<String, String> event) {
            String value = event.getValue();
            System.out.println(value);
        }
    }

    public static class Interceptor implements MapInterceptor {
        public Object interceptGet(Object value) {
            return value;
        }

        public void afterGet(Object value) {

        }

        public Object interceptPut(Object oldValue, Object newValue) {
            return "foo";
        }

        public void afterPut(Object value) {

        }

        public Object interceptRemove(Object removedValue) {
            return null;
        }

        public void afterRemove(Object value) {

        }
    }


}

@jerrinot jerrinot added this to the 3.7 milestone Apr 28, 2016

@jerrinot

This comment has been minimized.

Copy link
Contributor

commented Apr 28, 2016

fixed by #7416

@jerrinot jerrinot closed this Apr 28, 2016

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.