In the context of our framework, we come across a metaspace issue due to the use of soft references in ConcurrentReferenceHashMap by default. That default can be set in the constructor but there are are some inner uses of that class relies on the default soft reference type. For example: ResolvableType
Can a change be performed to provide a way to set the reference types in this cases this without using reflection? Passing the reference type to ResolvableType for example. Thanks!
Comment From: fsgonz
https://github.com/spring-projects/spring-framework/blob/master/spring-core/src/main/java/org/springframework/core/ResolvableType.java#L94
Comment From: jhoeller
The problem with the reference types is that ´weak´ does not necessarily make sense in such places since the key is not held on to, like in ResolvableType
. Switching this to weak references might be almost equivalent to having no cache at all...
If your problem is with specific internal caches there, could you elaborate on the specifics that you're seeing? Could you maybe call ResolvableType.clearCache()
at certain points? Is there anything else we could offer as a remedy for your scenario?
Comment From: eze210
Hello, is it possible to make the field DEFAULT_REFERENCE_TYPE
configurable? I understand that changing the default could lead to unexpected behaviors, so I don't suggest changing the default, but just making the field configurable with a setter or making it public.
Apart of the ResolvableType
cache, there are several caches in the framework, and some of them can't be cleared by using the API methods. For example, the one present in BridgeMethodResolver
Thanks!
Comment From: bclozel
Closing as a duplicate of https://github.com/spring-projects/spring-framework/issues/23284#issuecomment-1782977382