Skip to content

Improve the performance of BeanInfo lookups in CachedIntrospectionResults [SPR-9014] #13653

Closed
@spring-projects-issues

Description

@spring-projects-issues

Yuri Khomich opened SPR-9014 and commented

Current implementation of org.springframework.beans.CachedIntrospectionResults relies on java.beans.Introspector for bean introspection. Although java.beans.Introspector provides a way to limit the amount of information being introspected, CachedIntrospectionResults always uses Introspector.getBeanInfo(beanClass) which effectively means Introspector.getBeanInfo(beanClass, Introspector.USE_ALL_BEANINFO):

private CachedIntrospectionResults(Class beanClass) throws BeansException {
	try {
		if (logger.isTraceEnabled()) {
			logger.trace("Getting BeanInfo for class [" + beanClass.getName() + "]");
		}
		this.beanInfo = Introspector.getBeanInfo(beanClass);

The use of USE_ALL_BEANINFO flag makes java.beans.Introspector use class loading heavily to discover possible bean info. Extensive class loading is a real performance issue in some specific environments where classes are loaded not from local file system but from other sources that can be much slower to access. As a result, the initialization of application context is slowed down by the order of magnitude.

It would be very helpful if CachedIntrospectionResults provided control over java.beans.Introspector by calling Introspector.getBeanInfo() with desired flags. Otherwise there is no straightforward way to restrict class loading made by java.beans.Introspector in the case when full introspection is not needed and causes severe performance drawback.


Affects: 3.0.7, 3.1 GA

Issue Links:

Backported to: 3.2.7

2 votes, 14 watchers

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)status: backportedAn issue that has been backported to maintenance branchestype: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions