Uploaded image for project: 'Solr'
  1. Solr
  2. SOLR-5885

solr/contrib/dataimporthandler/src/java/org/apache/solr/handler/dataimport/SimplePropertiesWriter.java has crazy locale lookup

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Won't Fix
    • 4.7
    • 4.9, 6.0
    • None

    Description

      SimplePropertiesWriter uses the following code to convert a string to a java.util.Locale:

          if(params.get(LOCALE) != null) {
            String localeStr = params.get(LOCALE);
            for (Locale l : Locale.getAvailableLocales()) {
              if(localeStr.equals(l.getDisplayName(Locale.ROOT))) {
                locale = l;
                break;
              }
            }
            if(locale==null) {
              throw new DataImportHandlerException(SEVERE, "Unsupported locale for PropertWriter: " + localeStr);
            }
          } else {
            locale = Locale.ROOT;
          }    
      

      This makes no sense to me. Before I fixed that in LUCENE-5540, it was using the "localized" display name of the locale for lookup.

      As we are on Java 7 in trunk and 4.x we can use the new API: Locale#forLanguageTag(String languageTag)

      This one is not dependent on current locale, does not use display name and follows standards (IETF BCP 47).

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              uschindler Uwe Schindler
              Votes:
              2 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: