Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8159420

The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 9
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b124
    • Verification:
      Verified

      Description

      LanguageRange.parse() method fails in locales such as Turkish. Reason is that the parse() method uses toLowerCase() method which when used the in locales like Turkish returns the range string containing characters which are not acceptable in the language-range.

      e.g.
      "HI-Deva".toLowerCase() in a Turkish locale returns "hı-deva", where 'ı' is the LATIN SMALL LETTER DOTLESS I character which is not a valid language-range character.


      Below code snippet can be used to reproduce the issue
      /*
      String ranges = "HI-Deva";
      String tags = "en, hi-deva";
      FilteringMode mode = EXTENDED_FILTERING;
      Locale.setDefault(new Locale("tr","TR")); //setting the turkish locale
      List<LanguageRange> priorityList = LanguageRange.parse(ranges); // throws IllegalArgumentException
      */

      It throws exception as:
      Exception in thread "main" java.lang.IllegalArgumentException: range=hı-deva
      at java.util.Locale$LanguageRange.<init>(java.base@9-internal/Locale.java:2908)
      at sun.util.locale.LocaleMatcher.parse(java.base@9-internal/LocaleMatcher.java:285)

      Expectation:
      range.toLowerCase() should work on the ROOT locale irrespective of other locales

      Actual:
      range.toLowerCase() is working as range.toLowerCase(Locale.getDefault()) which fails in locales like turkish

        Attachments

          Activity

            People

            • Assignee:
              nishjain Nishit Jain
              Reporter:
              nishjain Nishit Jain
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: