Ian Rogers wrote:
> How can then the thread local be resurrected after the finalizer is
> run?
>
> All the references in ThreadLocal and InheritableThreadLocal are weak
> and will be atomically cleared prior to the finalizer being run. All
> other references must be dead for the finalizer to have been run.

This is not true. Once an object becomes "finalizer reachable" the finalizer 
can run, but that doesn't mean all references are gone. Any object with a 
finalizer can still have references to objects that have already been 
finalized. In its finalizer it will be able to resurrect these objects. This is 
a well known attack vector and the reason that PhantomReferences were 
introduced to do post-mortem cleanup.

Regards,
Jeroen


Reply via email to