<Beans Dev> RFR: 8231454: File lock in Windows on a loaded jar due to a leak in Introspector::getBeanInfo
Sergey Bylokhov
serb at openjdk.java.net
Wed Oct 14 05:27:23 UTC 2020
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.
-------------
Commit messages:
- Update FlushClassInfoCache.java
- Initial fix
Changes: https://git.openjdk.java.net/jdk/pull/647/files
Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=647&range=00
Issue: https://bugs.openjdk.java.net/browse/JDK-8231454
Stats: 113 lines in 3 files changed: 109 ins; 1 del; 3 mod
Patch: https://git.openjdk.java.net/jdk/pull/647.diff
Fetch: git fetch https://git.openjdk.java.net/jdk pull/647/head:pull/647
PR: https://git.openjdk.java.net/jdk/pull/647
More information about the beans-dev
mailing list