From 824939d7e58b2e5dacc7df610fa3244239253cd3 Mon Sep 17 00:00:00 2001 From: Robert Muir Date: Mon, 17 May 2010 17:18:10 +0000 Subject: [PATCH] LUCENE-2466: fix locale bugs for tr_TR locale: casing problems in lucene/solr code git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@945245 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/lucene/analysis/TestCharArrayMap.java | 2 +- .../lucene/analysis/TestKeywordMarkerFilter.java | 3 ++- solr/CHANGES.txt | 2 ++ .../solr/handler/dataimport/MailEntityProcessor.java | 3 ++- .../apache/solr/handler/dataimport/DataImporter.java | 7 ++++--- .../apache/solr/handler/dataimport/DocBuilder.java | 3 +-- .../handler/dataimport/NumberFormatTransformer.java | 2 +- .../dataimport/TestCachedSqlEntityProcessor.java | 5 +++-- .../handler/extraction/ExtractingDocumentLoader.java | 3 ++- solr/lib/commons-codec-1.3.jar | 2 -- solr/lib/commons-codec-1.4.jar | 2 ++ .../org/apache/solr/common/params/CommonParams.java | 4 +++- .../apache/solr/common/params/CoreAdminParams.java | 4 +++- .../org/apache/solr/common/params/FacetParams.java | 9 +++++---- .../solr/common/params/MoreLikeThisParams.java | 4 +++- .../apache/solr/common/util/ContentStreamBase.java | 3 ++- .../common/org/apache/solr/common/util/StrUtils.java | 3 ++- .../apache/solr/analysis/PhoneticFilterFactory.java | 12 +++++++----- solr/src/java/org/apache/solr/core/Config.java | 4 +++- .../java/org/apache/solr/core/JmxMonitoredMap.java | 2 +- solr/src/java/org/apache/solr/core/SolrConfig.java | 2 +- solr/src/java/org/apache/solr/core/SolrCore.java | 4 ++-- .../solr/handler/admin/ShowFileRequestHandler.java | 7 ++++--- .../apache/solr/handler/admin/SystemInfoHandler.java | 3 ++- .../solr/handler/component/TermsComponent.java | 3 ++- solr/src/java/org/apache/solr/schema/TrieField.java | 3 ++- solr/src/java/org/apache/solr/schema/UUIDField.java | 7 ++++--- .../java/org/apache/solr/update/SolrIndexWriter.java | 3 ++- .../client/solrj/beans/DocumentObjectBinder.java | 3 ++- .../solr/client/solrj/impl/XMLResponseParser.java | 8 +++++--- solr/src/test/org/apache/solr/core/TestConfig.java | 3 ++- .../solr/request/TestBinaryResponseWriter.java | 3 ++- .../org/apache/solr/servlet/SolrRequestParsers.java | 5 +++-- .../src/org/apache/solr/servlet/cache/Method.java | 4 +++- solr/src/webapp/web/admin/analysis.jsp | 2 +- 35 files changed, 86 insertions(+), 53 deletions(-) delete mode 100644 solr/lib/commons-codec-1.3.jar create mode 100644 solr/lib/commons-codec-1.4.jar diff --git a/lucene/src/test/org/apache/lucene/analysis/TestCharArrayMap.java b/lucene/src/test/org/apache/lucene/analysis/TestCharArrayMap.java index 7765001f3c1..eb5925a2234 100644 --- a/lucene/src/test/org/apache/lucene/analysis/TestCharArrayMap.java +++ b/lucene/src/test/org/apache/lucene/analysis/TestCharArrayMap.java @@ -36,7 +36,7 @@ public class TestCharArrayMap extends LuceneTestCase { key[j] = (char)r.nextInt(127); } String keyStr = new String(key); - String hmapKey = ignoreCase ? keyStr.toLowerCase() : keyStr; + String hmapKey = ignoreCase ? keyStr.toLowerCase(Locale.ENGLISH) : keyStr; int val = r.nextInt(); diff --git a/lucene/src/test/org/apache/lucene/analysis/TestKeywordMarkerFilter.java b/lucene/src/test/org/apache/lucene/analysis/TestKeywordMarkerFilter.java index ddc0b6d65da..4f4ced45dd6 100644 --- a/lucene/src/test/org/apache/lucene/analysis/TestKeywordMarkerFilter.java +++ b/lucene/src/test/org/apache/lucene/analysis/TestKeywordMarkerFilter.java @@ -3,6 +3,7 @@ package org.apache.lucene.analysis; import java.io.IOException; import java.io.StringReader; import java.util.HashSet; +import java.util.Locale; import java.util.Set; import org.apache.lucene.analysis.tokenattributes.KeywordAttribute; @@ -64,7 +65,7 @@ public class TestKeywordMarkerFilter extends BaseTokenStreamTestCase { public boolean incrementToken() throws IOException { if (input.incrementToken()) { if (!keywordAttr.isKeyword()) { - final String term = termAtt.toString().toLowerCase(); + final String term = termAtt.toString().toLowerCase(Locale.ENGLISH); termAtt.setEmpty().append(term); } return true; diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index b6bb55143a0..1018ab7abc3 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -378,6 +378,8 @@ Build * SOLR-1891: Make lucene-jars-to-solr fail if copying any of the jars fails, and update clean to remove the jars in that directory (Mark Miller) +* LUCENE-2466: Commons-Codec was upgraded from 1.3 to 1.4. (rmuir) + Documentation ---------------------- diff --git a/solr/contrib/dataimporthandler/src/extras/main/java/org/apache/solr/handler/dataimport/MailEntityProcessor.java b/solr/contrib/dataimporthandler/src/extras/main/java/org/apache/solr/handler/dataimport/MailEntityProcessor.java index 7e464bf3f20..938335a5097 100644 --- a/solr/contrib/dataimporthandler/src/extras/main/java/org/apache/solr/handler/dataimport/MailEntityProcessor.java +++ b/solr/contrib/dataimporthandler/src/extras/main/java/org/apache/solr/handler/dataimport/MailEntityProcessor.java @@ -17,6 +17,7 @@ package org.apache.solr.handler.dataimport; import com.sun.mail.imap.IMAPMessage; + import org.apache.tika.config.TikaConfig; import org.apache.tika.utils.ParseUtils; import org.slf4j.Logger; @@ -161,7 +162,7 @@ public class MailEntityProcessor extends EntityProcessorBase { if (!processAttachment || (disp != null && disp.equalsIgnoreCase(Part.ATTACHMENT))) return; InputStream is = part.getInputStream(); String fileName = part.getFileName(); - String content = ParseUtils.getStringContent(is, TikaConfig.getDefaultConfig(), ctype.getBaseType().toLowerCase()); + String content = ParseUtils.getStringContent(is, TikaConfig.getDefaultConfig(), ctype.getBaseType().toLowerCase(Locale.ENGLISH)); if (disp != null && disp.equalsIgnoreCase(Part.ATTACHMENT)) { if (row.get(ATTACHMENT) == null) row.put(ATTACHMENT, new ArrayList()); diff --git a/solr/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DataImporter.java b/solr/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DataImporter.java index 0b33119e21f..e522a051441 100644 --- a/solr/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DataImporter.java +++ b/solr/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DataImporter.java @@ -22,6 +22,7 @@ import org.apache.solr.core.SolrCore; import org.apache.solr.schema.IndexSchema; import org.apache.solr.schema.SchemaField; import org.apache.solr.common.util.ContentStream; + import static org.apache.solr.handler.dataimport.DataImportHandlerException.wrapAndThrow; import static org.apache.solr.handler.dataimport.DataImportHandlerException.SEVERE; import org.slf4j.Logger; @@ -98,7 +99,7 @@ public class DataImporter { loadDataConfig(dataConfig); for (Map.Entry entry : schema.getFields().entrySet()) { - config.lowerNameVsSchemaField.put(entry.getKey().toLowerCase(), entry.getValue()); + config.lowerNameVsSchemaField.put(entry.getKey().toLowerCase(Locale.ENGLISH), entry.getValue()); } for (DataConfig.Entity e : config.document.entities) { @@ -125,7 +126,7 @@ public class DataImporter { DataConfig.Field fld = entry.getValue(); SchemaField field = schema.getFieldOrNull(fld.getName()); if (field == null) { - field = config.lowerNameVsSchemaField.get(fld.getName().toLowerCase()); + field = config.lowerNameVsSchemaField.get(fld.getName().toLowerCase(Locale.ENGLISH)); if (field == null) { LOG.info("The field :" + fld.getName() + " present in DataConfig does not have a counterpart in Solr Schema"); } @@ -215,7 +216,7 @@ public class DataImporter { } SchemaField schemaField = schema.getFieldOrNull(f.getName()); if (schemaField == null) { - schemaField = config.lowerNameVsSchemaField.get(f.getName().toLowerCase()); + schemaField = config.lowerNameVsSchemaField.get(f.getName().toLowerCase(Locale.ENGLISH)); if (schemaField != null) f.name = schemaField.getName(); } if (schemaField != null) { diff --git a/solr/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DocBuilder.java b/solr/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DocBuilder.java index ab49f6b7ad1..a6ecb0331e6 100644 --- a/solr/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DocBuilder.java +++ b/solr/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DocBuilder.java @@ -21,7 +21,6 @@ import org.apache.solr.common.SolrInputDocument; import org.apache.solr.core.SolrCore; import static org.apache.solr.handler.dataimport.SolrWriter.LAST_INDEX_KEY; import static org.apache.solr.handler.dataimport.DataImportHandlerException.*; -import static org.apache.solr.handler.dataimport.DataImportHandlerException.wrapAndThrow; import org.apache.solr.schema.SchemaField; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -744,7 +743,7 @@ public class DocBuilder { // This can be a dynamic field or a field which does not have an entry in data-config ( an implicit field) SchemaField sf = dataImporter.getSchema().getFieldOrNull(key); if (sf == null) { - sf = dataImporter.getConfig().lowerNameVsSchemaField.get(key.toLowerCase()); + sf = dataImporter.getConfig().lowerNameVsSchemaField.get(key.toLowerCase(Locale.ENGLISH)); } if (sf != null) { addFieldToDoc(entry.getValue(), sf.getName(), 1.0f, sf.multiValued(), doc); diff --git a/solr/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/NumberFormatTransformer.java b/solr/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/NumberFormatTransformer.java index 00bad109615..fa89d443ae5 100644 --- a/solr/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/NumberFormatTransformer.java +++ b/solr/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/NumberFormatTransformer.java @@ -72,7 +72,7 @@ public class NumberFormatTransformer extends Transformer { } Object val = row.get(srcCol); - String styleSmall = style.toLowerCase(); + String styleSmall = style.toLowerCase(Locale.ENGLISH); if (val instanceof List) { List inputs = (List) val; diff --git a/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestCachedSqlEntityProcessor.java b/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestCachedSqlEntityProcessor.java index 633a17645bd..391eb6f8a7e 100644 --- a/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestCachedSqlEntityProcessor.java +++ b/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestCachedSqlEntityProcessor.java @@ -21,6 +21,7 @@ import org.junit.Test; import java.util.ArrayList; import java.util.List; +import java.util.Locale; import java.util.Map; /** @@ -111,7 +112,7 @@ public class TestCachedSqlEntityProcessor { if (r == null) break; rows.add(r); - Assert.assertEquals(r.get("desc").toString().toUpperCase(), r.get("desc")); + Assert.assertEquals(r.get("desc").toString().toUpperCase(Locale.ENGLISH), r.get("desc")); } Assert.assertEquals(2, rows.size()); Assert.assertEquals(2, rows.get(0).size()); @@ -178,7 +179,7 @@ public class TestCachedSqlEntityProcessor { Object val = entry.getValue(); if (val instanceof String) { String s = (String) val; - entry.setValue(s.toUpperCase()); + entry.setValue(s.toUpperCase(Locale.ENGLISH)); } } return row; diff --git a/solr/contrib/extraction/src/main/java/org/apache/solr/handler/extraction/ExtractingDocumentLoader.java b/solr/contrib/extraction/src/main/java/org/apache/solr/handler/extraction/ExtractingDocumentLoader.java index a887a6f29e7..b79aeff17e4 100644 --- a/solr/contrib/extraction/src/main/java/org/apache/solr/handler/extraction/ExtractingDocumentLoader.java +++ b/solr/contrib/extraction/src/main/java/org/apache/solr/handler/extraction/ExtractingDocumentLoader.java @@ -48,6 +48,7 @@ import org.xml.sax.SAXException; import java.io.IOException; import java.io.InputStream; import java.io.StringWriter; +import java.util.Locale; /** @@ -135,7 +136,7 @@ public class ExtractingDocumentLoader extends ContentStreamLoader { String streamType = req.getParams().get(ExtractingParams.STREAM_TYPE, null); if (streamType != null) { //Cache? Parsers are lightweight to construct and thread-safe, so I'm told - MediaType mt = MediaType.parse(streamType.trim().toLowerCase()); + MediaType mt = MediaType.parse(streamType.trim().toLowerCase(Locale.ENGLISH)); parser = config.getParser(mt); } else { parser = autoDetectParser; diff --git a/solr/lib/commons-codec-1.3.jar b/solr/lib/commons-codec-1.3.jar deleted file mode 100644 index 41a0921bf9f..00000000000 --- a/solr/lib/commons-codec-1.3.jar +++ /dev/null @@ -1,2 +0,0 @@ -AnyObjectId[957b6752af9a60c1bb2a4f65db0e90e5ce00f521] was removed in git history. -Apache SVN contains full history. \ No newline at end of file diff --git a/solr/lib/commons-codec-1.4.jar b/solr/lib/commons-codec-1.4.jar new file mode 100644 index 00000000000..97a58157492 --- /dev/null +++ b/solr/lib/commons-codec-1.4.jar @@ -0,0 +1,2 @@ +AnyObjectId[458d432da88b0efeab640c229903fb5aad274044] was removed in git history. +Apache SVN contains full history. \ No newline at end of file diff --git a/solr/src/common/org/apache/solr/common/params/CommonParams.java b/solr/src/common/org/apache/solr/common/params/CommonParams.java index bed310abb1d..c5e446a5e54 100755 --- a/solr/src/common/org/apache/solr/common/params/CommonParams.java +++ b/solr/src/common/org/apache/solr/common/params/CommonParams.java @@ -17,6 +17,8 @@ package org.apache.solr.common.params; +import java.util.Locale; + /** * Parameters used across many handlers @@ -101,7 +103,7 @@ public interface CommonParams { public static EchoParamStyle get( String v ) { if( v != null ) { - v = v.toUpperCase(); + v = v.toUpperCase(Locale.ENGLISH); if( v.equals( "EXPLICIT" ) ) { return EXPLICIT; } diff --git a/solr/src/common/org/apache/solr/common/params/CoreAdminParams.java b/solr/src/common/org/apache/solr/common/params/CoreAdminParams.java index 8e387be807f..6a6e7268a9c 100644 --- a/solr/src/common/org/apache/solr/common/params/CoreAdminParams.java +++ b/solr/src/common/org/apache/solr/common/params/CoreAdminParams.java @@ -18,6 +18,8 @@ package org.apache.solr.common.params; +import java.util.Locale; + /** * @since solr 1.3 */ @@ -74,7 +76,7 @@ public interface CoreAdminParams { if( p != null ) { try { - return CoreAdminAction.valueOf( p.toUpperCase() ); + return CoreAdminAction.valueOf( p.toUpperCase(Locale.ENGLISH) ); } catch( Exception ex ) {} } diff --git a/solr/src/common/org/apache/solr/common/params/FacetParams.java b/solr/src/common/org/apache/solr/common/params/FacetParams.java index 7a8bbc8b457..17f2557a454 100644 --- a/solr/src/common/org/apache/solr/common/params/FacetParams.java +++ b/solr/src/common/org/apache/solr/common/params/FacetParams.java @@ -20,6 +20,7 @@ package org.apache.solr.common.params; import org.apache.solr.common.SolrException; import java.util.EnumSet; +import java.util.Locale; /** * Facet parameters @@ -170,10 +171,10 @@ public interface FacetParams { */ public enum FacetDateOther { BEFORE, AFTER, BETWEEN, ALL, NONE; - public String toString() { return super.toString().toLowerCase(); } + public String toString() { return super.toString().toLowerCase(Locale.ENGLISH); } public static FacetDateOther get(String label) { try { - return valueOf(label.toUpperCase()); + return valueOf(label.toUpperCase(Locale.ENGLISH)); } catch (IllegalArgumentException e) { throw new SolrException (SolrException.ErrorCode.BAD_REQUEST, @@ -217,10 +218,10 @@ public interface FacetParams { */ public enum FacetDateInclude { ALL, LOWER, UPPER, EDGE, OUTER; - public String toString() { return super.toString().toLowerCase(); } + public String toString() { return super.toString().toLowerCase(Locale.ENGLISH); } public static FacetDateInclude get(String label) { try { - return valueOf(label.toUpperCase()); + return valueOf(label.toUpperCase(Locale.ENGLISH)); } catch (IllegalArgumentException e) { throw new SolrException (SolrException.ErrorCode.BAD_REQUEST, diff --git a/solr/src/common/org/apache/solr/common/params/MoreLikeThisParams.java b/solr/src/common/org/apache/solr/common/params/MoreLikeThisParams.java index 9ca6ad3ecf8..c60c34c5628 100644 --- a/solr/src/common/org/apache/solr/common/params/MoreLikeThisParams.java +++ b/solr/src/common/org/apache/solr/common/params/MoreLikeThisParams.java @@ -17,6 +17,8 @@ package org.apache.solr.common.params; +import java.util.Locale; + /** * @since solr 1.3 */ @@ -57,7 +59,7 @@ public interface MoreLikeThisParams public static TermStyle get( String p ) { if( p != null ) { - p = p.toUpperCase(); + p = p.toUpperCase(Locale.ENGLISH); if( p.equals( "DETAILS" ) ) { return DETAILS; } diff --git a/solr/src/common/org/apache/solr/common/util/ContentStreamBase.java b/solr/src/common/org/apache/solr/common/util/ContentStreamBase.java index b0967b4de05..5ba7f440600 100755 --- a/solr/src/common/org/apache/solr/common/util/ContentStreamBase.java +++ b/solr/src/common/org/apache/solr/common/util/ContentStreamBase.java @@ -28,6 +28,7 @@ import java.io.Reader; import java.io.StringReader; import java.net.URL; import java.net.URLConnection; +import java.util.Locale; /** @@ -51,7 +52,7 @@ public abstract class ContentStreamBase implements ContentStream public static String getCharsetFromContentType( String contentType ) { if( contentType != null ) { - int idx = contentType.toLowerCase().indexOf( "charset=" ); + int idx = contentType.toLowerCase(Locale.ENGLISH).indexOf( "charset=" ); if( idx > 0 ) { return contentType.substring( idx + "charset=".length() ).trim(); } diff --git a/solr/src/common/org/apache/solr/common/util/StrUtils.java b/solr/src/common/org/apache/solr/common/util/StrUtils.java index 9ac05124caa..80b7c61c991 100644 --- a/solr/src/common/org/apache/solr/common/util/StrUtils.java +++ b/solr/src/common/org/apache/solr/common/util/StrUtils.java @@ -20,6 +20,7 @@ package org.apache.solr.common.util; import java.util.List; import java.util.ArrayList; import java.util.Collections; +import java.util.Locale; import java.io.IOException; import org.apache.solr.common.SolrException; @@ -207,7 +208,7 @@ public class StrUtils { public static List toLower(List strings) { ArrayList ret = new ArrayList(strings.size()); for (String str : strings) { - ret.add(str.toLowerCase()); + ret.add(str.toLowerCase(Locale.ENGLISH)); } return ret; } diff --git a/solr/src/java/org/apache/solr/analysis/PhoneticFilterFactory.java b/solr/src/java/org/apache/solr/analysis/PhoneticFilterFactory.java index e3845188f34..344c8196a3e 100644 --- a/solr/src/java/org/apache/solr/analysis/PhoneticFilterFactory.java +++ b/solr/src/java/org/apache/solr/analysis/PhoneticFilterFactory.java @@ -19,6 +19,7 @@ package org.apache.solr.analysis; import java.lang.reflect.Method; import java.util.HashMap; +import java.util.Locale; import java.util.Map; import org.apache.commons.codec.Encoder; @@ -28,6 +29,7 @@ import org.apache.commons.codec.language.RefinedSoundex; import org.apache.commons.codec.language.Soundex; import org.apache.lucene.analysis.TokenStream; import org.apache.solr.common.SolrException; +import org.apache.solr.common.util.StrUtils; /** * Create tokens based on phonetic encoders @@ -50,10 +52,10 @@ public class PhoneticFilterFactory extends BaseTokenFilterFactory private static final Map> registry; static { registry = new HashMap>(); - registry.put( "DoubleMetaphone".toUpperCase(), DoubleMetaphone.class ); - registry.put( "Metaphone".toUpperCase(), Metaphone.class ); - registry.put( "Soundex".toUpperCase(), Soundex.class ); - registry.put( "RefinedSoundex".toUpperCase(), RefinedSoundex.class ); + registry.put( "DoubleMetaphone".toUpperCase(Locale.ENGLISH), DoubleMetaphone.class ); + registry.put( "Metaphone".toUpperCase(Locale.ENGLISH), Metaphone.class ); + registry.put( "Soundex".toUpperCase(Locale.ENGLISH), Soundex.class ); + registry.put( "RefinedSoundex".toUpperCase(Locale.ENGLISH), RefinedSoundex.class ); } protected boolean inject = true; @@ -71,7 +73,7 @@ public class PhoneticFilterFactory extends BaseTokenFilterFactory throw new SolrException( SolrException.ErrorCode.SERVER_ERROR, "Missing required parameter: "+ENCODER +" ["+registry.keySet()+"]" ); } - Class clazz = registry.get(name.toUpperCase()); + Class clazz = registry.get(name.toUpperCase(Locale.ENGLISH)); if( clazz == null ) { throw new SolrException( SolrException.ErrorCode.SERVER_ERROR, "Unknown encoder: "+name +" ["+registry.keySet()+"]" ); } diff --git a/solr/src/java/org/apache/solr/core/Config.java b/solr/src/java/org/apache/solr/core/Config.java index 8efae403c2e..e0ec47de760 100644 --- a/solr/src/java/org/apache/solr/core/Config.java +++ b/solr/src/java/org/apache/solr/core/Config.java @@ -22,6 +22,7 @@ import org.w3c.dom.Node; import org.xml.sax.SAXException; import org.apache.solr.common.SolrException; import org.apache.solr.common.util.DOMUtil; + import javax.xml.parsers.*; import javax.xml.xpath.XPath; import javax.xml.xpath.XPathFactory; @@ -31,6 +32,7 @@ import javax.xml.namespace.QName; import java.io.*; import java.util.Arrays; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.LinkedHashMap; import java.util.Collections; @@ -285,7 +287,7 @@ public class Config { private static final AtomicBoolean versionWarningAlreadyLogged = new AtomicBoolean(false); public static final Version parseLuceneVersionString(final String matchVersion) { - String parsedMatchVersion = matchVersion.toUpperCase(); + String parsedMatchVersion = matchVersion.toUpperCase(Locale.ENGLISH); // be lenient with the supplied version parameter parsedMatchVersion = parsedMatchVersion.replaceFirst("^(\\d)\\.(\\d)$", "LUCENE_$1$2"); diff --git a/solr/src/java/org/apache/solr/core/JmxMonitoredMap.java b/solr/src/java/org/apache/solr/core/JmxMonitoredMap.java index 534218a0662..15c956ffe30 100644 --- a/solr/src/java/org/apache/solr/core/JmxMonitoredMap.java +++ b/solr/src/java/org/apache/solr/core/JmxMonitoredMap.java @@ -243,7 +243,7 @@ public class JmxMonitoredMap extends if (staticStats.contains(attribute) && attribute != null && attribute.length() > 0) { try { - String getter = "get" + attribute.substring(0, 1).toUpperCase() + String getter = "get" + attribute.substring(0, 1).toUpperCase(Locale.ENGLISH) + attribute.substring(1); Method meth = infoBean.getClass().getMethod(getter); val = meth.invoke(infoBean); diff --git a/solr/src/java/org/apache/solr/core/SolrConfig.java b/solr/src/java/org/apache/solr/core/SolrConfig.java index e3ccaa737b8..5c7a173d5ca 100644 --- a/solr/src/java/org/apache/solr/core/SolrConfig.java +++ b/solr/src/java/org/apache/solr/core/SolrConfig.java @@ -367,7 +367,7 @@ public class SolrConfig extends Config { /** Input must not be null */ public static LastModFrom parse(final String s) { try { - return valueOf(s.toUpperCase()); + return valueOf(s.toUpperCase(Locale.ENGLISH)); } catch (Exception e) { log.warn( "Unrecognized value for lastModFrom: " + s, e); return BOGUS; diff --git a/solr/src/java/org/apache/solr/core/SolrCore.java b/solr/src/java/org/apache/solr/core/SolrCore.java index f22506ae242..33df970480a 100644 --- a/solr/src/java/org/apache/solr/core/SolrCore.java +++ b/solr/src/java/org/apache/solr/core/SolrCore.java @@ -1554,14 +1554,14 @@ public final class SolrCore implements SolrInfoMBean { File configdir = new File( solrConfig.getResourceLoader().getConfigDir() ); if( configdir.exists() && configdir.isDirectory() ) { for( String file : configdir.list() ) { - hide.add( file.toUpperCase() ); + hide.add( file.toUpperCase(Locale.ENGLISH) ); } } // except the "gettable" list StringTokenizer st = new StringTokenizer( gettable ); while( st.hasMoreTokens() ) { - hide.remove( st.nextToken().toUpperCase() ); + hide.remove( st.nextToken().toUpperCase(Locale.ENGLISH) ); } for( String s : hide ) { invariants.add( ShowFileRequestHandler.HIDDEN, s ); diff --git a/solr/src/java/org/apache/solr/handler/admin/ShowFileRequestHandler.java b/solr/src/java/org/apache/solr/handler/admin/ShowFileRequestHandler.java index 50cc92ff0b2..4ae2f2a57e0 100644 --- a/solr/src/java/org/apache/solr/handler/admin/ShowFileRequestHandler.java +++ b/solr/src/java/org/apache/solr/handler/admin/ShowFileRequestHandler.java @@ -22,6 +22,7 @@ import java.io.IOException; import java.io.InputStream; import java.util.Date; import java.util.HashSet; +import java.util.Locale; import java.util.Set; import org.apache.commons.io.IOUtils; @@ -105,7 +106,7 @@ public class ShowFileRequestHandler extends RequestHandlerBase String[] hidden = invariants.getParams( HIDDEN ); if( hidden != null ) { for( String s : hidden ) { - hiddenFiles.add( s.toUpperCase() ); + hiddenFiles.add( s.toUpperCase(Locale.ENGLISH) ); } } } @@ -129,7 +130,7 @@ public class ShowFileRequestHandler extends RequestHandlerBase } else { fname = fname.replace( '\\', '/' ); // normalize slashes - if( hiddenFiles.contains( fname.toUpperCase() ) ) { + if( hiddenFiles.contains( fname.toUpperCase(Locale.ENGLISH) ) ) { throw new SolrException( ErrorCode.FORBIDDEN, "Can not access: "+fname ); } if( fname.indexOf( ".." ) >= 0 ) { @@ -156,7 +157,7 @@ public class ShowFileRequestHandler extends RequestHandlerBase for( File f : adminFile.listFiles() ) { String path = f.getAbsolutePath().substring( basePath ); path = path.replace( '\\', '/' ); // normalize slashes - if( hiddenFiles.contains( path.toUpperCase() ) ) { + if( hiddenFiles.contains( path.toUpperCase(Locale.ENGLISH) ) ) { continue; // don't show 'hidden' files } if( f.isHidden() || f.getName().startsWith( "." ) ) { diff --git a/solr/src/java/org/apache/solr/handler/admin/SystemInfoHandler.java b/solr/src/java/org/apache/solr/handler/admin/SystemInfoHandler.java index 078a75e54c9..8d0606ccef5 100644 --- a/solr/src/java/org/apache/solr/handler/admin/SystemInfoHandler.java +++ b/solr/src/java/org/apache/solr/handler/admin/SystemInfoHandler.java @@ -28,6 +28,7 @@ import java.lang.reflect.Method; import java.net.InetAddress; import java.text.DecimalFormat; import java.util.Date; +import java.util.Locale; import org.apache.commons.io.IOUtils; import org.apache.lucene.LucenePackage; @@ -122,7 +123,7 @@ public class SystemInfoHandler extends RequestHandlerBase addGetterIfAvaliable( os, "processCpuTime", info ); try { - if( !os.getName().toLowerCase().startsWith( "windows" ) ) { + if( !os.getName().toLowerCase(Locale.ENGLISH).startsWith( "windows" ) ) { // Try some command line things info.add( "uname", execute( "uname -a" ) ); info.add( "ulimit", execute( "ulimit -n" ) ); diff --git a/solr/src/java/org/apache/solr/handler/component/TermsComponent.java b/solr/src/java/org/apache/solr/handler/component/TermsComponent.java index dbb7fec025e..04d60d90d7b 100644 --- a/solr/src/java/org/apache/solr/handler/component/TermsComponent.java +++ b/solr/src/java/org/apache/solr/handler/component/TermsComponent.java @@ -36,6 +36,7 @@ import java.util.Arrays; import java.util.Comparator; import java.util.HashMap; import java.util.List; +import java.util.Locale; import java.util.regex.Pattern; /** @@ -186,7 +187,7 @@ public class TermsComponent extends SearchComponent { int flags = 0; for (String flagParam : flagParams) { try { - flags |= TermsParams.TermsRegexpFlag.valueOf(flagParam.toUpperCase()).getValue(); + flags |= TermsParams.TermsRegexpFlag.valueOf(flagParam.toUpperCase(Locale.ENGLISH)).getValue(); } catch (IllegalArgumentException iae) { throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Unknown terms regex flag '" + flagParam + "'"); } diff --git a/solr/src/java/org/apache/solr/schema/TrieField.java b/solr/src/java/org/apache/solr/schema/TrieField.java index 850bdbe12c1..2a9c67f5821 100644 --- a/solr/src/java/org/apache/solr/schema/TrieField.java +++ b/solr/src/java/org/apache/solr/schema/TrieField.java @@ -31,6 +31,7 @@ import org.apache.solr.search.QParser; import org.apache.solr.search.function.*; import java.io.IOException; +import java.util.Locale; import java.util.Map; import java.util.Date; @@ -77,7 +78,7 @@ public class TrieField extends FieldType { if (t != null) { try { - type = TrieTypes.valueOf(t.toUpperCase()); + type = TrieTypes.valueOf(t.toUpperCase(Locale.ENGLISH)); } catch (IllegalArgumentException e) { throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Invalid type specified in schema.xml for field: " + args.get("name"), e); diff --git a/solr/src/java/org/apache/solr/schema/UUIDField.java b/solr/src/java/org/apache/solr/schema/UUIDField.java index 91306cdc199..594427536fd 100644 --- a/solr/src/java/org/apache/solr/schema/UUIDField.java +++ b/solr/src/java/org/apache/solr/schema/UUIDField.java @@ -18,6 +18,7 @@ package org.apache.solr.schema; */ import java.io.IOException; +import java.util.Locale; import java.util.Map; import java.util.UUID; @@ -76,7 +77,7 @@ public class UUIDField extends FieldType { @Override public String toInternal(String val) { if (val == null || 0==val.length() || NEW.equals(val)) { - return UUID.randomUUID().toString().toLowerCase(); + return UUID.randomUUID().toString().toLowerCase(Locale.ENGLISH); } else { // we do some basic validation if 'val' looks like an UUID if (val.length() != 36 || val.charAt(8) != DASH || val.charAt(13) != DASH @@ -85,12 +86,12 @@ public class UUIDField extends FieldType { "Invalid UUID String: '" + val + "'"); } - return val.toLowerCase(); + return val.toLowerCase(Locale.ENGLISH); } } public String toInternal(UUID uuid) { - return uuid.toString().toLowerCase(); + return uuid.toString().toLowerCase(Locale.ENGLISH); } @Override diff --git a/solr/src/java/org/apache/solr/update/SolrIndexWriter.java b/solr/src/java/org/apache/solr/update/SolrIndexWriter.java index 2bfcbc552ab..c79ad1ac343 100644 --- a/solr/src/java/org/apache/solr/update/SolrIndexWriter.java +++ b/solr/src/java/org/apache/solr/update/SolrIndexWriter.java @@ -36,6 +36,7 @@ import java.io.OutputStream; import java.io.PrintStream; import java.text.DateFormat; import java.util.Date; +import java.util.Locale; /** * An IndexWriter that is configured via Solr config mechanisms. @@ -121,7 +122,7 @@ public class SolrIndexWriter extends IndexWriter { log.warn("No lockType configured for " + path + " assuming 'simple'"); rawLockType = "simple"; } - final String lockType = rawLockType.toLowerCase().trim(); + final String lockType = rawLockType.toLowerCase(Locale.ENGLISH).trim(); if ("simple".equals(lockType)) { // multiple SimpleFSLockFactory instances should be OK diff --git a/solr/src/solrj/org/apache/solr/client/solrj/beans/DocumentObjectBinder.java b/solr/src/solrj/org/apache/solr/client/solrj/beans/DocumentObjectBinder.java index 834f089dec4..f01cb9dc17d 100644 --- a/solr/src/solrj/org/apache/solr/client/solrj/beans/DocumentObjectBinder.java +++ b/solr/src/solrj/org/apache/solr/client/solrj/beans/DocumentObjectBinder.java @@ -19,6 +19,7 @@ package org.apache.solr.client.solrj.beans; import org.apache.solr.common.SolrDocumentList; import org.apache.solr.common.SolrDocument; import org.apache.solr.common.SolrInputDocument; + import java.lang.reflect.*; import java.util.*; import java.util.regex.Pattern; @@ -178,7 +179,7 @@ public class DocumentObjectBinder { } else { String setterName = setter.getName(); if (setterName.startsWith("set") && setterName.length() > 3) { - name = setterName.substring(3, 4).toLowerCase() + setterName.substring(4); + name = setterName.substring(3, 4).toLowerCase(Locale.ENGLISH) + setterName.substring(4); } else { name = setter.getName(); } diff --git a/solr/src/solrj/org/apache/solr/client/solrj/impl/XMLResponseParser.java b/solr/src/solrj/org/apache/solr/client/solrj/impl/XMLResponseParser.java index 77b6210e75b..58a4932e413 100644 --- a/solr/src/solrj/org/apache/solr/client/solrj/impl/XMLResponseParser.java +++ b/solr/src/solrj/org/apache/solr/client/solrj/impl/XMLResponseParser.java @@ -22,6 +22,8 @@ import java.io.InputStream; import java.util.ArrayList; import java.util.Date; import java.util.List; +import java.util.Locale; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -187,7 +189,7 @@ public class XMLResponseParser extends ResponseParser { if( v != null ) { try { - return KnownType.valueOf( v.toUpperCase() ); + return KnownType.valueOf( v.toUpperCase(Locale.ENGLISH) ); } catch( Exception ex ) {} } @@ -267,7 +269,7 @@ public class XMLResponseParser extends ResponseParser if( XMLStreamConstants.START_ELEMENT != parser.getEventType() ) { throw new RuntimeException( "must be start element, not: "+parser.getEventType() ); } - if( !"arr".equals( parser.getLocalName().toLowerCase() ) ) { + if( !"arr".equals( parser.getLocalName().toLowerCase(Locale.ENGLISH) ) ) { throw new RuntimeException( "must be 'arr', not: "+parser.getLocalName() ); } @@ -370,7 +372,7 @@ public class XMLResponseParser extends ResponseParser if( XMLStreamConstants.START_ELEMENT != parser.getEventType() ) { throw new RuntimeException( "must be start element, not: "+parser.getEventType() ); } - if( !"doc".equals( parser.getLocalName().toLowerCase() ) ) { + if( !"doc".equals( parser.getLocalName().toLowerCase(Locale.ENGLISH) ) ) { throw new RuntimeException( "must be 'lst', not: "+parser.getLocalName() ); } diff --git a/solr/src/test/org/apache/solr/core/TestConfig.java b/solr/src/test/org/apache/solr/core/TestConfig.java index 6df1682b7e8..2c42fa7e449 100644 --- a/solr/src/test/org/apache/solr/core/TestConfig.java +++ b/solr/src/test/org/apache/solr/core/TestConfig.java @@ -35,6 +35,7 @@ import static org.junit.Assert.*; import javax.xml.xpath.XPathConstants; import java.io.IOException; import java.io.InputStream; +import java.util.Locale; public class TestConfig extends SolrTestCaseJ4 { @@ -112,7 +113,7 @@ public class TestConfig extends SolrTestCaseJ4 { //System.out.println( handler.getHiddenFiles() ); // should not contain: solrconfig.xml scheam.xml admin-extra.html - assertFalse(handler.getHiddenFiles().contains("scheam.xml".toUpperCase())); + assertFalse(handler.getHiddenFiles().contains("scheam.xml".toUpperCase(Locale.ENGLISH))); assertTrue(handler.getHiddenFiles().contains("PROTWORDS.TXT")); } diff --git a/solr/src/test/org/apache/solr/request/TestBinaryResponseWriter.java b/solr/src/test/org/apache/solr/request/TestBinaryResponseWriter.java index 2e202f0f8e6..b4fa04df3bc 100644 --- a/solr/src/test/org/apache/solr/request/TestBinaryResponseWriter.java +++ b/solr/src/test/org/apache/solr/request/TestBinaryResponseWriter.java @@ -27,6 +27,7 @@ import org.apache.solr.util.AbstractSolrTestCase; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; +import java.util.Locale; import java.util.UUID; /** @@ -49,7 +50,7 @@ public class TestBinaryResponseWriter extends AbstractSolrTestCase { * Tests known types implementation by asserting correct encoding/decoding of UUIDField */ public void testUUID() throws Exception { - String s = UUID.randomUUID().toString().toLowerCase(); + String s = UUID.randomUUID().toString().toLowerCase(Locale.ENGLISH); assertU(adoc("id", "101", "uuid", s)); assertU(commit()); LocalSolrQueryRequest req = lrf.makeRequest("q", "*:*"); diff --git a/solr/src/webapp/src/org/apache/solr/servlet/SolrRequestParsers.java b/solr/src/webapp/src/org/apache/solr/servlet/SolrRequestParsers.java index 9465c5375ff..c61fc10b464 100644 --- a/solr/src/webapp/src/org/apache/solr/servlet/SolrRequestParsers.java +++ b/solr/src/webapp/src/org/apache/solr/servlet/SolrRequestParsers.java @@ -28,6 +28,7 @@ import java.util.Collection; import java.util.HashMap; import java.util.Iterator; import java.util.List; +import java.util.Locale; import java.util.Map; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -378,7 +379,7 @@ class StandardRequestParser implements SolrRequestParser public SolrParams parseParamsAndFillStreams( final HttpServletRequest req, ArrayList streams ) throws Exception { - String method = req.getMethod().toUpperCase(); + String method = req.getMethod().toUpperCase(Locale.ENGLISH); if( "GET".equals( method ) || "HEAD".equals( method )) { return new ServletSolrParams(req); } @@ -389,7 +390,7 @@ class StandardRequestParser implements SolrRequestParser if( idx > 0 ) { // remove the charset definition "; charset=utf-8" contentType = contentType.substring( 0, idx ); } - if( "application/x-www-form-urlencoded".equals( contentType.toLowerCase() ) ) { + if( "application/x-www-form-urlencoded".equals( contentType.toLowerCase(Locale.ENGLISH) ) ) { return new ServletSolrParams(req); // just get the params from parameterMap } if( ServletFileUpload.isMultipartContent(req) ) { diff --git a/solr/src/webapp/src/org/apache/solr/servlet/cache/Method.java b/solr/src/webapp/src/org/apache/solr/servlet/cache/Method.java index 9c793b29c5d..5477f6a485f 100644 --- a/solr/src/webapp/src/org/apache/solr/servlet/cache/Method.java +++ b/solr/src/webapp/src/org/apache/solr/servlet/cache/Method.java @@ -17,12 +17,14 @@ package org.apache.solr.servlet.cache; +import java.util.Locale; + public enum Method { GET, POST, HEAD, OTHER; public static Method getMethod(String method) { try { - return Method.valueOf(method.toUpperCase()); + return Method.valueOf(method.toUpperCase(Locale.ENGLISH)); } catch (Exception e) { return OTHER; } diff --git a/solr/src/webapp/web/admin/analysis.jsp b/solr/src/webapp/web/admin/analysis.jsp index bd756df9369..5a9f2f965d4 100644 --- a/solr/src/webapp/web/admin/analysis.jsp +++ b/solr/src/webapp/web/admin/analysis.jsp @@ -46,7 +46,7 @@ // is name a field name or a type name? String nt = request.getParameter("nt"); if (nt==null || nt.length()==0) nt="name"; // assume field name - nt = nt.toLowerCase().trim(); + nt = nt.toLowerCase(Locale.ENGLISH).trim(); String name = request.getParameter("name"); if (name==null || name.length()==0) name=""; String val = request.getParameter("val");