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

Duplicate QueryCache listeners #13402

Closed
neilstevenson opened this issue Jul 4, 2018 · 1 comment
Closed

Duplicate QueryCache listeners #13402

neilstevenson opened this issue Jul 4, 2018 · 1 comment

Comments

@neilstevenson
Copy link
Contributor

@neilstevenson neilstevenson commented Jul 4, 2018

In AbstractInternalQueryCache the private method getQueryCacheConfig() is called in multiple places.

This in turn calls
NodeQueryCacheConfigurator public method getOrCreateConfiguration(mapName,cacheName,cacheId)

And this calls AbstractQueryCacheConfigurator the method setEntryListener(MapName,cacheId,config) adds the listener.

The net effect being the listener is added more than once, event handling is duplicated.

Tested on 3.10.2, on server side, but looks like the same issue client side.

@ahmetmircik ahmetmircik added this to the 3.10.3 milestone Jul 5, 2018
@ahmetmircik ahmetmircik self-assigned this Jul 5, 2018
@neilstevenson
Copy link
Contributor Author

@neilstevenson neilstevenson commented Jul 5, 2018

Reproducer:

public class Issue13402 {

	public static void main(String[] args) throws Exception {
		EntryListenerConfig entryListenerConfig = new EntryListenerConfig();
		entryListenerConfig.setImplementation(new Issue13042Listener());
		entryListenerConfig.setIncludeValue(false);
		entryListenerConfig.setLocal(true);
    	
		QueryCacheConfig queryCacheConfig = new QueryCacheConfig("neilCache");
		queryCacheConfig.getPredicateConfig().setImplementation(Predicates.alwaysTrue());
		queryCacheConfig.addEntryListenerConfig(entryListenerConfig);
		
    	MapConfig mapConfig = new MapConfig("neilMap");
    	mapConfig.getQueryCacheConfigs().add(queryCacheConfig);
    	
    	Config config = new Config();
		config.getMapConfigs().put("neilMap", mapConfig);
		
		HazelcastInstance hazelcastInstance = Hazelcast.newHazelcastInstance(config);

		IMap<Integer, String> neilMap = hazelcastInstance.getMap("neilMap");
		QueryCache<Integer, String>  neilCache = neilMap.getQueryCache("neilCache");
		
		for (int i = 0 ; i < 2 ; i++) {
			System.out.println("'" + neilMap.getName() + "' size==" + neilMap.size());
			System.out.println("'" + neilMap.getName() + "' cache size==" + neilCache.size());
			neilMap.set(i, "test");
			TimeUnit.SECONDS.sleep(1L);
		}

    	hazelcastInstance.shutdown();
    }

	static class Issue13042Listener implements EntryAddedListener<Integer, String> {
		@Override
		public void entryAdded(EntryEvent<Integer, String> event) {
			System.out.println(this.getClass().getSimpleName() + "@" + System.identityHashCode(this) 
				+ "," + event.getClass().getName() + "@" + System.identityHashCode(event)
				+ "," + event);
		}
	}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

3 participants
You can’t perform that action at this time.