No Filter on method finalize for Proxy
--------------------------------------
Key: JCR-2046
URL: https://issues.apache.org/jira/browse/JCR-2046
Project: Jackrabbit Content Repository
Issue Type: Bug
Components: jackrabbit-ocm
Reporter: Sandrine Raffalli
The InvocationHandler of a proxy is called when the method finalize() is
called, that means the proxy loads the object when the GC tries to delete it.
Adding a CallbackFilter to the Enhancer could be a solution to avoid that :
public class ProxyManagerImpl implements ProxyManager {
private static final CallbackFilter FINALIZE_FILTER = new
CallbackFilter() {
public int accept(Method method) {
if (method.getParameterTypes().length == 0 &&
method.getName().equals("finalize")) {
return 1;
} else {
return 0;
}
}
};
...
public Object createBeanProxy(BeanConverter beanConverter, String path,
Session session, Node parentNode, BeanDescriptor beanDescriptor,
ClassDescriptor beanClassDescriptor, Class beanClass,
Object parent) {
...
return Enhancer.create(beanClass, getInterfaces(beanClass),
FINALIZE_FILTER, new Callback[] { loader });
}
...
public Object createCollectionProxy(Session session,
CollectionConverter collectionConverter, Node parentNode,
CollectionDescriptor collectionDescriptor, Class
collectionFieldClass) {
....
return Enhancer.create(collectionFieldClass,
getInterfaces(collectionFieldClass), FINALIZE_FILTER, new Callback[] { loader
});
}
...
}
Maybe you may consider other methods such as "equals", "hashCode"...
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.