Uploaded image for project: 'Lucene - Core'
  1. Lucene - Core
  2. LUCENE-4021

Locale representations don't round trip from toString->new Locale.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • None
    • None
    • None
    • None
    • New

    Description

      The script and extensions are not currently parsed. Seems like they were added in 1.7 only too so it'll probably require Java-version-specific workarounds.

        public void testLocaleRoundTrip() {
          for (Locale locale : Locale.getAvailableLocales()) {
            String s = locale.toString();
            try {
              Locale back = LuceneTestCase.localeForName(s);
              assertEquals(locale, back);
            } catch (Exception e) {
              System.err.println("Failed roundtrip: " + s + " (" + e.toString() + ")");
            } catch (AssertionError e) {
              System.err.println("Not equals: " + s + " (" + e.toString() + ")");
            }
          }
        }
      

      Example locales that don't pass.

      th_TH_TH_#u-nu-thai
      ja_JP_JP_#u-ca-japanese
      

      Interestingly, some that do pass the reverse trip are not .equal to their originals:

      Not equals: sr_ME_#Latn (java.lang.AssertionError: expected: java.util.Locale<sr_ME_#Latn> but was: java.util.Locale<sr_ME_#Latn>)
      Not equals: sr_BA_#Latn (java.lang.AssertionError: expected: java.util.Locale<sr_BA_#Latn> but was: java.util.Locale<sr_BA_#Latn>)
      Not equals: sr__#Latn (java.lang.AssertionError: expected: java.util.Locale<sr__#Latn> but was: java.util.Locale<sr__#Latn>)
      Not equals: sr_RS_#Latn (java.lang.AssertionError: expected: java.util.Locale<sr_RS_#Latn> but was: java.util.Locale<sr_RS_#Latn>)
      

      Attachments

        1. LUCENE-4021.patch
          2 kB
          Robert Muir

        Activity

          People

            Unassigned Unassigned
            dweiss Dawid Weiss
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: