Uploaded image for project: 'Commons Lang'
  1. Commons Lang
  2. LANG-1260

LocaleUtils.toLocale() produces arbitrary locales

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 3.4
    • None
    • None
    • None

    Description

      When passing an invalid locale string (len != 2 && len != 5 && len < 7) to org.apache.commons.lang3.LocaleUtils#toLocale(String) the method would previously (3.1) throw an IllegalArgumentException.

      With version 3.4 the method will – at least for any string with len == 3 – create an arbitrary locale:

      // GIVEN
      String localeString = "xyz";
      // WHEN
      Locale xyz = LocaleUtils.toLocale(localeString);
      // THEN
      assertEquals(xyz.toString(), localeString); // What?
      

      We are relying on this behaviour (IllegalArgumentException) and were quite surprised to not find any mention in the changelog.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              pmundt Philip Mundt
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated: