You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In some situations (in this case a hibernate-cglib-wrapped class implementing a generic interface), calling 'BeanUtils.getPropertyDescriptor' on any property of the class results in an IllegalStateException.
After some inspection, it seems BridgeMethodResolver recognises 2 candidate functions when looking for the bridge method, but upon closer inspection, decides neither of them should be chosen.
Attached is a simple, reasonable self-contained unittest demonstrating the problem. The problem does not seem to occur in Spring versions prior to 2.5.6.
Tested with hibernate 3.2.6.ga
java.lang.IllegalStateException: Unable to locate bridged method for bridge method 'public final void nl.topicuszorg.wicket.hibernate.test.CGLibTest$CglibInstantieMedewerker$$EnhancerByCGLIB$$540fe4f7.setOrganisatie(nl.topicuszorg.wicket.hibernate.test.CGLibTest$CglibIOrganisatie)'
at org.springframework.core.BridgeMethodResolver.findBridgedMethod(BridgeMethodResolver.java:86)
at org.springframework.beans.GenericTypeAwarePropertyDescriptor.<init>(GenericTypeAwarePropertyDescriptor.java:59)
at org.springframework.beans.CachedIntrospectionResults.<init>(CachedIntrospectionResults.java:250)
at org.springframework.beans.CachedIntrospectionResults.forClass(CachedIntrospectionResults.java:144)
at org.springframework.beans.BeanUtils.getPropertyDescriptor(BeanUtils.java:329)
at nl.topicuszorg.wicket.hibernate.test.CGLibTest.testCGLib(CGLibTest.java:51)
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:597)
at junit.framework.TestCase.runTest(TestCase.java:168)
at junit.framework.TestCase.runBare(TestCase.java:134)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:81)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Thanks for pointing this out! This is a bit of strange generics-based arrangement, with IntelliJ IDEA even flagging the leaf subclass as invalid because of no setter being declared for the specific generic type that the subclass declares... That said - IntelliJ then nevertheless compiles the class when forced to! According to the Java compiler, it is valid.
In any case, as of 3.0 M2, Spring's bridge method resolution works with Hibernate-generated CGLIB proxies as well.
This is not scheduled for backporting at present, since we haven't had much chance for researching side effects yet. Also, Spring 3.0 comes with several enhancements that better support the use of generics in bean property methods... So this change is in good company within Spring 3.0 - as part of a larger whole.
Uh oh!
There was an error while loading. Please reload this page.
Arnout Engelen opened SPR-5414 and commented
In some situations (in this case a hibernate-cglib-wrapped class implementing a generic interface), calling 'BeanUtils.getPropertyDescriptor' on any property of the class results in an IllegalStateException.
After some inspection, it seems BridgeMethodResolver recognises 2 candidate functions when looking for the bridge method, but upon closer inspection, decides neither of them should be chosen.
Attached is a simple, reasonable self-contained unittest demonstrating the problem. The problem does not seem to occur in Spring versions prior to 2.5.6.
Tested with hibernate 3.2.6.ga
java.lang.IllegalStateException: Unable to locate bridged method for bridge method 'public final void nl.topicuszorg.wicket.hibernate.test.CGLibTest$CglibInstantieMedewerker$$EnhancerByCGLIB$$540fe4f7.setOrganisatie(nl.topicuszorg.wicket.hibernate.test.CGLibTest$CglibIOrganisatie)'
at org.springframework.core.BridgeMethodResolver.findBridgedMethod(BridgeMethodResolver.java:86)
at org.springframework.beans.GenericTypeAwarePropertyDescriptor.<init>(GenericTypeAwarePropertyDescriptor.java:59)
at org.springframework.beans.CachedIntrospectionResults.<init>(CachedIntrospectionResults.java:250)
at org.springframework.beans.CachedIntrospectionResults.forClass(CachedIntrospectionResults.java:144)
at org.springframework.beans.BeanUtils.getPropertyDescriptor(BeanUtils.java:329)
at nl.topicuszorg.wicket.hibernate.test.CGLibTest.testCGLib(CGLibTest.java:51)
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:597)
at junit.framework.TestCase.runTest(TestCase.java:168)
at junit.framework.TestCase.runBare(TestCase.java:134)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:81)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Affects: 2.5.6
Attachments:
Sub-tasks:
@Lazy
volatile" annotated public propertiesReferenced from: commits 15bbd57
The text was updated successfully, but these errors were encountered: