Optimize ClassUtils#getMostSpecificMethod
#30272
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
status: backported
An issue that has been backported to maintenance branches
type: enhancement
A general enhancement
Milestone
Hi,
I've been profiling some (test-)application context starts lately on Spring Framework 5.x and noticed that with one of our medium-larger applications - which I'm unfortunately not able to share - that during startup almost 100K exceptions are being thrown (caused by some Aspects not in our control). The large majority of this is ending up in
ClassUtils.getMostSpecificMethod
. The majority of cases seems to be caused by checking for the static factory methods onMap.of
,Map.ofEntries
etc. with the target classProperties
where we already now that they won't exist. (Properties
is checked because Spring Data repositories have an inner bean for the named queries, I believe)I can't imagine this to be super fast or efficient. Could we do anything about that? I'm wondering if it would make sense to exclude
static
methods here in the first place. Or have some sort of pre-defined list of methods or classes that we know won't find certain things. Or caching the lookups etc.We haven't been able to upgrade these apps so far to 6.x because the Spring-Security changes are blocking us from a smoother upgrade, but a quick check also revealed that nothing really drastically changed in that regards in the codebase and the risk of checking for methods that are known to not exist still applies. Having that said, there might be a chance that this particular issue for us is reduced with spring-projects/spring-data-commons@712477b but I haven't been able to confirm this just yet.
Anyhow, I'd appreciate if you could take a look if this can be somehow improved.
Cheers,
Christoph
The text was updated successfully, but these errors were encountered: