[hibernate-issues] [Hibernate-JIRA] Updated: (HHH-2316) org.hibernate.cache.CacheKey.equals() can cause PropertyAccessException to be thrown

Jifeng Liu (JIRA) noreply at atlassian.com
Wed Apr 18 17:46:04 EDT 2007


     [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2316?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jifeng Liu updated HHH-2316:
----------------------------

    Attachment: cacheTest.zip

I created a test case in the attached zip file. The exception's stack trace is:

org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of org.hibernate.test.annotations.cidcache.OrderLinePk.firstname
	at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:171)
	at org.hibernate.tuple.component.AbstractComponentTuplizer.getPropertyValue(AbstractComponentTuplizer.java:64)
	at org.hibernate.tuple.component.AbstractComponentTuplizer.getPropertyValues(AbstractComponentTuplizer.java:70)
	at org.hibernate.tuple.component.PojoComponentTuplizer.getPropertyValues(PojoComponentTuplizer.java:83)
	at org.hibernate.type.ComponentType.getPropertyValues(ComponentType.java:353)
	at org.hibernate.type.ComponentType.isEqual(ComponentType.java:123)
	at org.hibernate.cache.CacheKey.equals(CacheKey.java:51)
	at java.util.HashMap.eq(HashMap.java:299)
	at java.util.HashMap.getEntry(HashMap.java:398)
	at java.util.LinkedHashMap.get(LinkedHashMap.java:273)
	at net.sf.ehcache.store.MemoryStore.get(MemoryStore.java:130)
	at net.sf.ehcache.Cache.searchInMemoryStore(Cache.java:819)
	at net.sf.ehcache.Cache.get(Cache.java:654)
	at org.hibernate.cache.EhCache.get(EhCache.java:74)
	at org.hibernate.cache.ReadWriteCache.afterInsert(ReadWriteCache.java:289)
	at org.hibernate.action.EntityInsertAction.afterTransactionCompletion(EntityInsertAction.java:169)
	at org.hibernate.engine.ActionQueue.afterTransactionCompletion(ActionQueue.java:170)
	at org.hibernate.impl.SessionImpl.afterTransactionCompletion(SessionImpl.java:424)
	at org.hibernate.jdbc.JDBCContext.afterTransactionCompletion(JDBCContext.java:225)
	at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:119)
	at org.hibernate.test.annotations.cidcache.CompositeIdCacheTest.testCache(CompositeIdCacheTest.java:32)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:585)
	at junit.framework.TestCase.runTest(TestCase.java:154)
	at org.hibernate.test.annotations.TestCase.runTest(TestCase.java:68)
	at junit.framework.TestCase.runBare(TestCase.java:127)
	at junit.framework.TestResult$1.protect(TestResult.java:106)
	at junit.framework.TestResult.runProtected(TestResult.java:124)
	at junit.framework.TestResult.run(TestResult.java:109)
	at junit.framework.TestCase.run(TestCase.java:118)
	at junit.framework.TestSuite.runTest(TestSuite.java:208)
	at junit.framework.TestSuite.run(TestSuite.java:203)
	at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:297)
	at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.launch(JUnitTestRunner.java:672)
	at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:567)
Caused by: java.lang.IllegalArgumentException: object is not an instance of declaring class
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:585)
	at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:145)
	... 36 more


> org.hibernate.cache.CacheKey.equals() can cause PropertyAccessException to be thrown
> ------------------------------------------------------------------------------------
>
>                 Key: HHH-2316
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2316
>             Project: Hibernate3
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 3.2.1
>         Environment: Windows XP / Sybase 12.5 / Java 1.5.0_09 / ehcache 1.2.4
>            Reporter: Joel Caplin
>            Priority: Critical
>         Attachments: cacheTest.zip
>
>
> org.hibernate.cache.CacheKey.equals() uses lazy evaluation in its return clause: it first calls type.isEqual() and, if true, then calls entityOrRoleName.equals().
> I am having difficulty reproducing this bug in the form of a test case owing to the complexity of our model and the large amount of data in question-- however, in certain circumstances, where the entityOrRoleName's are NOT equal, calling type.isEqual() yields a PropertyAccessException.
> When this bug manifests itself (a PropertyAccessException is thrown), it causes ALL future Hibernate requests to throw a similar exception, thus rendering our service unusable.
> This is fixed when the lazy evaluation is done the other way around: call entityOrRoleName.equals() prior to type.isEqual() - cheap string comparision vs an expensive call which has a large call tree under it.

-- 
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