Uploaded image for project: 'MyFaces Core'
  1. MyFaces Core
  2. MYFACES-4330

[perf] Bad performance of ResourceHandlerImpl because of unnecessary MissingResourceException

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.2.12
    • 2.2.13, 2.3.7, 3.0.0-RC1, 2.3-next-M3
    • None
    • None

    Description

      While processing JSF resource requests a lot of MissingResourceExceptions are thrown and catched right afterwards if you have a message bundle installed but no resource for the key 'javax.faces.resource.localePrefix' is provided (like in the case of Primefaces).

      This can lead to performance problems because creating and throwing an exception is a heavy operation. The throwing of the exception can be prevented by first checking if a resource contains a certain resource before accessing it:
      try {
      ResourceBundle bundle = ResourceBundle
      .getBundle(bundleName, locale, ClassUtils.getContextClassLoader()); if (bundle != null)

      { if (bundle.containsKey(ResourceHandler.LOCALE_PREFIX)) \{ localePrefix = bundle.getString(ResourceHandler.LOCALE_PREFIX); }

      }
      } catch (MissingResourceException e)

      { // Ignore it and return null }

      By applying the above patch I see a 50% reduction of the execution time of the method createResource.

      Attachments

        1. myfaces.patch
          0.8 kB
          Reto Weiss

        Activity

          People

            Unassigned Unassigned
            reto.weiss@ivyteam.ch Reto Weiss
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: