<Beans Dev> RFR: 8231454: File lock in Windows on a loaded jar due to a leak in Introspector::getBeanInfo

Alexander Zuev kizune at openjdk.java.net
Tue Oct 20 21:47:13 UTC 2020


On Wed, 14 Oct 2020 05:18:23 GMT, Sergey Bylokhov <serb at openjdk.org> wrote:

> java.beans.Introspector is using a new cache mechanism since Java9 in com.sun.beans.introspect.ClassInfo::CACHE which
> uses a SoftReference cache over the class, which makes the class "leak", unless clearing the cache manually or
> collecting the SoftReference by the GC.  Note that this is not a pure "leak", because the SoftReference will be
> collected if there is no enough memory on the system, but if the heap is big enough then all objects referenced from
> the cached class will be in the memory.  The class has a reference to the ClassLoader, and If the soft reference to the
> class is not collected by the GC, then the ClassLoader cannot be unloaded and this block the jar file removing.
> The solution is to update the implementation of Introspector.flushCaches()/flushFromCaches(Class) to clear the whole
> cache or the cache for the specific class.

Looks good.

-------------

Marked as reviewed by kizune (Reviewer).

PR: https://git.openjdk.java.net/jdk/pull/647


More information about the beans-dev mailing list