[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-2021) org.hibernate.cache.QueryKey has a fragile equals() method

Rafal Boniecki (JIRA) noreply at atlassian.com
Mon Aug 13 06:59:13 EDT 2007


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2021?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_27805 ] 

Rafal Boniecki commented on HHH-2021:
-------------------------------------

This issue is much more important than it may seem at first - especially for JBoss Cache users. Under high load with Query Cache enabled there is following exception thrown:

2007-08-06 17:21:46,347 ERROR [STDERR] Exception in thread "Timer-3"
2007-08-06 17:21:46,347 ERROR [STDERR] java.lang.ClassCastException: org.hibernate.cache.CacheKey cannot be cast to org.hibernate.cache.QueryKey
2007-08-06 17:21:46,348 ERROR [STDERR]  at org.hibernate.cache.QueryKey.equals(QueryKey.java:54)
2007-08-06 17:21:46,348 ERROR [STDERR]  at java.util.AbstractList.equals(AbstractList.java:507)
2007-08-06 17:21:46,348 ERROR [STDERR]  at org.jboss.cache.Fqn.equals(Unknown Source)
2007-08-06 17:21:46,348 ERROR [STDERR]  at java.util.HashMap.removeEntryForKey(HashMap.java:556)
2007-08-06 17:21:46,348 ERROR [STDERR]  at java.util.HashMap.remove(HashMap.java:538)
2007-08-06 17:21:46,348 ERROR [STDERR]  at java.util.LinkedHashMap$LinkedHashIterator.remove(LinkedHashMap.java:366)
2007-08-06 17:21:46,348 ERROR [STDERR]  at org.jboss.cache.eviction.LRUAlgorithm.prune(Unknown Source)
2007-08-06 17:21:46,348 ERROR [STDERR]  at org.jboss.cache.eviction.BaseEvictionAlgorithm.process(Unknown Source)
2007-08-06 17:21:46,349 ERROR [STDERR]  at org.jboss.cache.eviction.EvictionTimerTask.run(Unknown Source)
2007-08-06 17:21:46,349 ERROR [STDERR]  at java.util.TimerThread.mainLoop(Timer.java:512)
2007-08-06 17:21:46,349 ERROR [STDERR]  at java.util.TimerThread.run(Timer.java:462)

which kills eviction queue thread (this thread empties eviction queue every defined amount of time). Without this thread eviction queue fills up and then JBoss stops responding. Adding instanceof check before cast as mentioned above makes the problem go away :)
Please fix this simple bug.

> 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