Uploaded image for project: 'XWiki Commons'
  1. XWiki Commons
  2. XCOMMONS-3908

Concurrent property conversions block each other on a lock shared by the whole JVM

    XMLWordPrintable

Details

    • Unit
    • Unknown
    • N/A
    • N/A

    Description

      Every conversion that falls back to ConvertUtilsConverter (the default Converter of the ConverterManager) takes a lock shared by the whole JVM. Under load, request threads queue on it and pages get slow even though neither the CPU nor the database is saturated.

      Impact

      On xwiki.org, Glowroot's aggregated profile of /xwiki/bin/view/Main/WebHome during a load spike (2026-11-18, 09:55–10:20 UTC, 69,955 samples) has 48% of the samples BLOCKED in org.apache.commons.beanutils.ContextClassLoaderLocal.get, reached from ConvertUtilsConverter.convert. The main callers were:

      • DefaultLoggerConfiguration.isDeprecatedLogEnabled (about 22,000 samples), which converts the logging.deprecated.enabled configuration property to a boolean each time a Velocity context is set up, e.g. for every icon rendered and every wiki UI extension's parameters;
      • DefaultBeanManager.populate (about 9,000 samples), i.e. macro parameters;
      • HibernateConfiguration.isMigrationEnabled (about 1,200 samples), called on every Hibernate transaction.

      Cause

      ConvertUtilsConverter calls the static ConvertUtils.convert, which gets its instance from BeanUtilsBean.getInstance(). BeanUtils keeps one instance per context class loader in a ContextClassLoaderLocal, whose get() method is synchronized on a single static object, so every conversion in the JVM goes through the same monitor.

      Because the instance depends on the context class loader, the strict converters that ConvertUtilsConverter#initialize() registers (throwing an exception instead of returning a default value) are only used under the context class loader that was active when the component was initialized. Request threads use their own context class loader (see ThreadClassloaderExecutionContextInitializer), so in practice an invalid value converted to a primitive type or its wrapper becomes false or 0, which is XCOMMONS-3847.

      Fix

      Make ConvertUtilsConverter use its own ConvertUtilsBean instance. To keep the behavior that request threads have today, and to keep the fix safe to backport, this instance uses the default (lenient) BeanUtils converters. Making invalid values fail is left to XCOMMONS-3847.

      Attachments

        Issue Links

          Activity

            People

              MichaelHamann Michael Hamann
              MichaelHamann Michael Hamann
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: