You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by "Jukka Zitting (JIRA)" <ji...@apache.org> on 2009/04/27 17:04:30 UTC
[jira] Updated: (OCM-5) No Filter on method finalize for Proxy
[ https://issues.apache.org/jira/browse/OCM-5?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Jukka Zitting updated OCM-5:
----------------------------
Description:
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 :
{code}
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 , NoOp.INSTANCE});
}
...
public Object createCollectionProxy(Session session, CollectionConverter collectionConverter, Node parentNode,
CollectionDescriptor collectionDescriptor, Class collectionFieldClass) {
....
return Enhancer.create(collectionFieldClass, getInterfaces(collectionFieldClass), FINALIZE_FILTER, new Callback[] { loader , NoOp.INSTANCE});
}
...
}
{code}
Maybe you may consider other methods such as "equals", "hashCode"...
was:
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 , NoOp.INSTANCE});
}
...
public Object createCollectionProxy(Session session, CollectionConverter collectionConverter, Node parentNode,
CollectionDescriptor collectionDescriptor, Class collectionFieldClass) {
....
return Enhancer.create(collectionFieldClass, getInterfaces(collectionFieldClass), FINALIZE_FILTER, new Callback[] { loader , NoOp.INSTANCE});
}
...
}
Maybe you may consider other methods such as "equals", "hashCode"...
> No Filter on method finalize for Proxy
> --------------------------------------
>
> Key: OCM-5
> URL: https://issues.apache.org/jira/browse/OCM-5
> Project: Jackrabbit OCM
> Issue Type: Bug
> 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 :
> {code}
> 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 , NoOp.INSTANCE});
> }
> ...
> public Object createCollectionProxy(Session session, CollectionConverter collectionConverter, Node parentNode,
> CollectionDescriptor collectionDescriptor, Class collectionFieldClass) {
> ....
> return Enhancer.create(collectionFieldClass, getInterfaces(collectionFieldClass), FINALIZE_FILTER, new Callback[] { loader , NoOp.INSTANCE});
> }
> ...
> }
> {code}
> 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.