groovy

Callsite caching breaks the use of Hibernate proxies when combined with inheritance

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Blocker Blocker
  • Resolution: Won't Fix
  • Affects Version/s: 1.6
  • Fix Version/s: 1.6.2, 1.7-beta-1
  • Component/s: None
  • Labels:
    None
  • Number of attachments :
    2

Description

I've attached an example script that demonstrates an issue with Groovy callsite caching when combined with Hibernate proxy usage. Accessing an association of an entity that is lazily loaded with a Hibernate proxy results in an IllegalArgumentException:

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.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)

This has is causing this issue in Grails: http://jira.codehaus.org/browse/GRAILS-4230

  1. ivysettings.xml
    26/Mar/09 8:23 AM
    1 kB
    Graeme Rocher
  2. TestScript.groovy
    26/Mar/09 8:23 AM
    3 kB
    Graeme Rocher

Activity

Hide
Graeme Rocher added a comment -

To add a little more detail. This is the line that causes the problem:

println "author = ${revision.content.author}" // THIS FAILS

It happens when accessing the "author" property of the "content" association. The "author" property is defined in a subclass called Article, what is interesting is that accessing properties from the parent class works fine:

println "author = ${revision.content.id}" // THIS WORKS
Show
Graeme Rocher added a comment - To add a little more detail. This is the line that causes the problem:
println "author = ${revision.content.author}" // THIS FAILS
It happens when accessing the "author" property of the "content" association. The "author" property is defined in a subclass called Article, what is interesting is that accessing properties from the parent class works fine:
println "author = ${revision.content.id}" // THIS WORKS
Hide
Marc Palmer added a comment -

Its also causing this separate Grails issue:

http://jira.codehaus.org/browse/GRAILS-4242

Show
Marc Palmer added a comment - Its also causing this separate Grails issue: http://jira.codehaus.org/browse/GRAILS-4242
Hide
Graeme Rocher added a comment -

This changes needs to be rolled back, as it caused a regression where Groovy now bypasses proxies all together hence breaking Spring proxies. See GROOVY-3480

Show
Graeme Rocher added a comment - This changes needs to be rolled back, as it caused a regression where Groovy now bypasses proxies all together hence breaking Spring proxies. See GROOVY-3480
Hide
Graeme Rocher added a comment -

The reason for this issue is that Hibernate is proxying the getMetaClass() method. See here for an explanation: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3870

Show
Graeme Rocher added a comment - The reason for this issue is that Hibernate is proxying the getMetaClass() method. See here for an explanation: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3870
Hide
blackdrag blackdrag added a comment -

for now I close this bug as won't fix, since Hibernate would be a better place to handle the issue

Show
blackdrag blackdrag added a comment - for now I close this bug as won't fix, since Hibernate would be a better place to handle the issue

People

Vote (3)
Watch (5)

Dates

  • Created:
    Updated:
    Resolved: