[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-2021) org.hibernate.cache.QueryKey has a fragile equals() method
Bernard Niset (JIRA)
noreply at atlassian.com
Mon Oct 22 03:50:39 EDT 2007
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2021?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_28505 ]
Bernard Niset commented on HHH-2021:
------------------------------------
I had the same problem when using EhCache. So, it seems important for EhCache users as well.
It seems to happen very rarely but it doesn't seem like minor issue as it completely crashes the application when the use case leading to it happens. Perhaps it should be investigated how this problem happens (mixing QueryKey elements and entities in the same cache region ?), but in the meanwhile it seems easy enough to fix.
Please note that the issue happened in a different case for me. I'll paste below the stacktrace that happened in my case.
2007-10-22 02:09:55,441 ERROR RuntimeException caught: org.hibernate.cache.CacheKey cannot be cast to
org.hibernate.cache.QueryKey
java.lang.ClassCastException: org.hibernate.cache.CacheKey cannot be cast to org.hibernate.cache.QueryKey
at org.hibernate.cache.QueryKey.equals(QueryKey.java:54)
at java.util.HashMap.removeEntryForKey(HashMap.java:556)
at java.util.LinkedHashMap.addEntry(LinkedHashMap.java:411)
at java.util.HashMap.put(HashMap.java:385)
at net.sf.ehcache.store.MemoryStore.put(MemoryStore.java:107)
at net.sf.ehcache.Cache.put(Cache.java:569)
at net.sf.ehcache.Cache.put(Cache.java:522)
at org.hibernate.cache.EhCache.put(EhCache.java:119)
at org.hibernate.cache.ReadWriteCache.put(ReadWriteCache.java:159)
at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:156)
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:854)
at org.hibernate.loader.Loader.doQuery(Loader.java:729)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
at org.hibernate.loader.Loader.doList(Loader.java:2220)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
at org.hibernate.loader.Loader.list(Loader.java:2099)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:378)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:338)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
> org.hibernate.cache.QueryKey has a fragile equals() method
> ----------------------------------------------------------
>
> Key: HHH-2021
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2021
> Project: Hibernate3
> Issue Type: Bug
> Components: core
> Affects Versions: 3.1.3
> Reporter: Kenny MacLeod
> Priority: Trivial
>
> This one is no great shakes, but the first line of QueryKey.equals() casts the argument to QueryKey without checking for its type. As such, the method is fragile.
> It should be consistent with CacheKey, which does an instanceof check before the cast.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list