Hi,
Could someone please explain this unexpected behavior using standalone JBoss Cache v1.2.3:
- I add a Map object to a TreeCacheAOP instance
- Retrieve the Map from the cache and call get method on map
- Just calling get causes the key queried for to be added to the Map. This does not follow the contract of standard Java Maps.
Output of the System.out lines in the below sample:
...
false
true
import java.util.HashMap; import java.util.Map; import org.jboss.cache.PropertyConfigurator; import org.jboss.cache.aop.TreeCacheAop; public class CacheMapTest { private static final String DB_TEST_MAP = "/db/testMap"; private static final String MY_KEY = "myKey"; public static void main(String[] args) throws Exception { TreeCacheAop cache = new TreeCacheAop(); PropertyConfigurator config = new PropertyConfigurator(); config.configure(cache, "META-INF/replSync-service.xml"); cache.startService(); cache.putObject(DB_TEST_MAP, new HashMap()); Map testMap = (Map) cache.getObject(DB_TEST_MAP); System.out.println(testMap.containsKey(MY_KEY)); testMap.get(MY_KEY); System.out.println(testMap.containsKey(MY_KEY)); } }
I believe this is bug that I accidentally introduced in 1.2.3 release when trying to ensure aotmic operation of get/put/remove-Object. It should be minor though.
It will be fixed in 1.2.4.
-Ben