Uploaded image for project: '[Read Only] - Hippo Site Toolkit 2'
  1. [Read Only] - Hippo Site Toolkit 2
  2. HSTTWO-1789

HippoDocument#getLocale should not throw an exception when the locale is invalid

    XMLWordPrintable

Details

    • Improvement
    • Status: Closed
    • Normal
    • Resolution: Fixed
    • 2.22.03
    • 2.22.04, 2.23.03
    • None
    • None

    Description

      HippoDocument#getLocale is using LocaleUtils#toLocale. This method throws an IllegalArgumentException when the locale is not null and invalid.

      I encountered a problem when the folder locale was missing, and the documents created in this folder had the invalid locale 'document-type-locale'. It was breaking some pages on the website.

      So I think it would be safer to catch and log this exception. My proposition:

      public Locale getLocale() {
      String localeString = getLocaleString();
      try

      { return LocaleUtils.toLocale(localeString); }

      catch(IllegalArgumentException e)

      { log.warn("Invalid locale " + localeString + " for document " + getPath(), e); }

      return null;
      }

      Attachments

        Activity

          People

            aschrijvers Ard Schrijvers
            mtricot Mickaƫl Tricot (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: