Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-9014

Improve the performance of BeanInfo lookups in CachedIntrospectionResults

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Complete
    • Affects Version/s: 3.0.7, 3.1 GA
    • Fix Version/s: 3.2.7, 4.0.1
    • Component/s: Core
    • Last commented by a User:
      true

      Description

      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):

      CachedIntrospectionResults.java
      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.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              juergen.hoeller Juergen Hoeller
              Reporter:
              wilmot ‚Äč
              Last updater:
              Spring Issues Spring Issues
              Votes:
              2 Vote for this issue
              Watchers:
              14 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Days since last comment:
                3 years, 37 weeks, 4 days ago