1st instance of AOP proxy leaks its advice #25505
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
status: superseded
An issue that has been superseded by another
Affects: 5.2.8.RELEASE
A programmer supplies an implementation of
org.aopalliance.aop.Advice
toProxyFactory.addAdvice()
. A custom advice may occupy a lot of memory, nobody forbids that. ThenProxyFactory.getProxy()
will generate a class for the current factory config and put it in a cache:Both key and value weakly refer to the custom Advice, however, there's a strong reference to the
ProxyCallbackFilter
from the generated class (I couldn't determine the exact field in the generated class, but Eclipse shows there's a reference)And this class is loaded in the application classloader and will not be collected. I think this is why the initial Advice instances are not collected.
There's no reason for the generated class to refer the original advices because when a new proxy is created, new advice instances are used even if their classes are the same. Also, I think maybe we shouldn't store the custom advices as part of the key.
ProxyCallbackFilter
only compares the advice classes and the advisor pointcuts in itsequals()
method.Here's the test program:
The text was updated successfully, but these errors were encountered: