• Bug
  • Status: Closed
  • 2 Major
  • Resolution: Fixed
  • juris
  • Reporter: ssubbiah
  • April 18, 2007
  • 0
  • Watchers: 1
  • July 27, 2012
  • April 23, 2007

Description

LinkedHashMap supports partial collections. Which means that it stores objectIDs instead of objects for values until it is needed. When the object is needed, its supposed to transparently fault it and give it to external world. This is not happening for removeEldestEntry() call which can be overriden by a subclass. This results in the following exception.

java.lang.ClassCastException: com.tc.object.ObjectID at net.sf.ehcache.store.LruMemoryStore$SpoolingLinkedHashMap.removeEldes tEntry(LruMemoryStore.java:18 at java.util.LinkedHashMap.addEntry(Unknown Source) at java.util.HashMap.__tc_put(Unknown Source) at java.util.HashMap.__tc_applicator_put(Unknown Source) at com.tc.object.applicator.HashMapApplicator.apply(HashMapApplicator.ja va:102) at com.tc.object.applicator.LinkedHashMapApplicator.apply(LinkedHashMapA pplicator.java:74) at com.tc.object.applicator.LinkedHashMapApplicator.hydrate(LinkedHashMa pApplicator.java:55) at com.tc.object.TCClassImpl.hydrate(TCClassImpl.java:152) at com.tc.object.TCObjectImpl.hydrate(TCObjectImpl.java:103) at com.tc.object.ClientObjectManagerImpl.lookup(ClientObjectManagerImpl. java:501) at com.tc.object.ClientObjectManagerImpl.lookupObject(ClientObjectManage rImpl.java:402) at com.tc.object.ClientObjectManagerImpl.lookupObject(ClientObjectManage rImpl.java:395) at com.tc.object.TCObjectPhysical.resolveReference(TCObjectPhysical.java :103) at net.sf.ehcache.store.MemoryStore.__tc_getmap(MemoryStore.java) at net.sf.ehcache.store.MemoryStore.__tc_wrapped_getKeyArray(MemoryStore .java:282) at net.sf.ehcache.store.MemoryStore.getKeyArray(MemoryStore.java) at net.sf.ehcache.Cache.__tc_wrapped_getKeys(Cache.java:731) at net.sf.ehcache.Cache.getKeys(Cache.java) at demo.jtable.DemoEHCache.showCache(DemoEHCache.java:54) at demo.jtable.DemoEHCache.askForUserInput(DemoEHCache.java:80) at demo.jtable.DemoEHCache.main(DemoEHCache.java:89) com.tc.object.dna.api.DNAException: java.lang.ClassCastException: com.tc.object. ObjectID at com.tc.object.TCObjectImpl.hydrate(TCObjectImpl.java:107) at com.tc.object.ClientObjectManagerImpl.lookup(ClientObjectManagerImpl. java:501) at com.tc.object.ClientObjectManagerImpl.lookupObject(ClientObjectManage rImpl.java:402) at com.tc.object.ClientObjectManagerImpl.lookupObject(ClientObjectManage rImpl.java:395) at com.tc.object.TCObjectPhysical.resolveReference(TCObjectPhysical.java :103) at net.sf.ehcache.store.MemoryStore.__tc_getmap(MemoryStore.java) at net.sf.ehcache.store.MemoryStore.__tc_wrapped_getKeyArray(MemoryStore .java:282) at net.sf.ehcache.store.MemoryStore.getKeyArray(MemoryStore.java) at net.sf.ehcache.Cache.__tc_wrapped_getKeys(Cache.java:731) at net.sf.ehcache.Cache.getKeys(Cache.java) at demo.jtable.DemoEHCache.showCache(DemoEHCache.java:54) at demo.jtable.DemoEHCache.askForUserInput(DemoEHCache.java:80) at demo.jtable.DemoEHCache.main(DemoEHCache.java:89) Caused by: java.lang.ClassCastException: com.tc.object.ObjectID at net.sf.ehcache.store.LruMemoryStore$SpoolingLinkedHashMap.removeEldes tEntry(LruMemoryStore.java:18 at java.util.LinkedHashMap.addEntry(Unknown Source) at java.util.HashMap.__tc_put(Unknown Source) at java.util.HashMap.__tc_applicator_put(Unknown Source) at com.tc.object.applicator.HashMapApplicator.apply(HashMapApplicator.ja va:102) at com.tc.object.applicator.LinkedHashMapApplicator.apply(LinkedHashMapA pplicator.java:74) at com.tc.object.applicator.LinkedHashMapApplicator.hydrate(LinkedHashMa pApplicator.java:55) at com.tc.object.TCClassImpl.hydrate(TCClassImpl.java:152) at com.tc.object.TCObjectImpl.hydrate(TCObjectImpl.java:103) … 12 more Exception in thread “main” com.tc.exception.TCRuntimeException: com.tc.object.dn a.api.DNAException: java.lang.ClassCastException: com.tc.object.ObjectID at com.tc.object.ClientObjectManagerImpl.lookup(ClientObjectManagerImpl. java:505) at com.tc.object.ClientObjectManagerImpl.lookupObject(ClientObjectManage rImpl.java:402) at com.tc.object.ClientObjectManagerImpl.lookupObject(ClientObjectManage rImpl.java:395) at com.tc.object.TCObjectPhysical.resolveReference(TCObjectPhysical.java :103) at net.sf.ehcache.store.MemoryStore.__tc_getmap(MemoryStore.java) at net.sf.ehcache.store.MemoryStore.__tc_wrapped_getKeyArray(MemoryStore .java:282) at net.sf.ehcache.store.MemoryStore.getKeyArray(MemoryStore.java) at net.sf.ehcache.Cache.__tc_wrapped_getKeys(Cache.java:731) at net.sf.ehcache.Cache.getKeys(Cache.java) at demo.jtable.DemoEHCache.showCache(DemoEHCache.java:54) at demo.jtable.DemoEHCache.askForUserInput(DemoEHCache.java:80) at demo.jtable.DemoEHCache.main(DemoEHCache.java:89) Caused by: com.tc.object.dna.api.DNAException: java.lang.ClassCastException: com .tc.object.ObjectID at com.tc.object.TCObjectImpl.hydrate(TCObjectImpl.java:107) at com.tc.object.ClientObjectManagerImpl.lookup(ClientObjectManagerImpl. java:501) … 11 more Caused by: java.lang.ClassCastException: com.tc.object.ObjectID at net.sf.ehcache.store.LruMemoryStore$SpoolingLinkedHashMap.removeEldes tEntry(LruMemoryStore.java:18 at java.util.LinkedHashMap.addEntry(Unknown Source) at java.util.HashMap.__tc_put(Unknown Source) at java.util.HashMap.__tc_applicator_put(Unknown Source) at com.tc.object.applicator.HashMapApplicator.apply(HashMapApplicator.ja va:102) at com.tc.object.applicator.LinkedHashMapApplicator.apply(LinkedHashMapA pplicator.java:74) at com.tc.object.applicator.LinkedHashMapApplicator.hydrate(LinkedHashMa pApplicator.java:55) at com.tc.object.TCClassImpl.hydrate(TCClassImpl.java:152) at com.tc.object.TCObjectImpl.hydrate(TCObjectImpl.java:103) … 12 more

Comments

Juris Galang 2007-04-23

We now have a LinkedHashMapClassAdapter that visits the addEntryMethod and wraps the argument to LinkedHashMap.addEntry(Map.Entry) in a HashMapTC.EntryWrapper prior to a call to LinkedHashMap.removeEldestEntry(…) inside the method. This fixes the ClassCastException thrown when an instrumented class extends java.util.LinkedHashMap and overrides the removeEldestEntry method.