LUCENE-2466: fix some usages of the default locale that cause test failures under th_TH_TH

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@945343 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2010-05-17 20:22:23 +00:00
parent 62307cb0b5
commit 82bc123339
8 changed files with 13 additions and 11 deletions

View File

@ -56,7 +56,7 @@ public class DateUtil {
private static final Date DEFAULT_TWO_DIGIT_YEAR_START; private static final Date DEFAULT_TWO_DIGIT_YEAR_START;
static { static {
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT"), Locale.US);
calendar.set(2000, Calendar.JANUARY, 1, 0, 0); calendar.set(2000, Calendar.JANUARY, 1, 0, 0);
DEFAULT_TWO_DIGIT_YEAR_START = calendar.getTime(); DEFAULT_TWO_DIGIT_YEAR_START = calendar.getTime();
} }
@ -185,7 +185,7 @@ public class DateUtil {
public ThreadLocalDateFormat() { public ThreadLocalDateFormat() {
super(); super();
//2007-04-26T08:05:04Z //2007-04-26T08:05:04Z
SimpleDateFormat tmp = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); SimpleDateFormat tmp = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.US);
tmp.setTimeZone(UTC); tmp.setTimeZone(UTC);
proto = tmp; proto = tmp;
} }

View File

@ -425,7 +425,7 @@ public class CoreContainer
schemaFile = new File(solrLoader.getInstanceDir() + "conf" + File.separator + dcore.getSchemaName()); schemaFile = new File(solrLoader.getInstanceDir() + "conf" + File.separator + dcore.getSchemaName());
} }
if(schemaFile. exists()){ if(schemaFile. exists()){
String key = schemaFile.getAbsolutePath()+":"+new SimpleDateFormat("yyyyMMddhhmmss").format(new Date(schemaFile.lastModified())); String key = schemaFile.getAbsolutePath()+":"+new SimpleDateFormat("yyyyMMddhhmmss", Locale.US).format(new Date(schemaFile.lastModified()));
schema = indexSchemaCache.get(key); schema = indexSchemaCache.get(key);
if(schema == null){ if(schema == null){
log.info("creating new schema object for core: " + dcore.name); log.info("creating new schema object for core: " + dcore.name);

View File

@ -481,7 +481,7 @@ public class SnapPuller {
* All the files are copied to a temp dir first * All the files are copied to a temp dir first
*/ */
private File createTempindexDir(SolrCore core) { private File createTempindexDir(SolrCore core) {
String tmpIdxDirName = "index." + new SimpleDateFormat(SnapShooter.DATE_FMT).format(new Date()); String tmpIdxDirName = "index." + new SimpleDateFormat(SnapShooter.DATE_FMT, Locale.US).format(new Date());
File tmpIdxDir = new File(core.getDataDir(), tmpIdxDirName); File tmpIdxDir = new File(core.getDataDir(), tmpIdxDirName);
tmpIdxDir.mkdirs(); tmpIdxDir.mkdirs();
return tmpIdxDir; return tmpIdxDir;
@ -649,7 +649,7 @@ public class SnapPuller {
} }
private String getDateAsStr(Date d) { private String getDateAsStr(Date d) {
return new SimpleDateFormat(SnapShooter.DATE_FMT).format(d); return new SimpleDateFormat(SnapShooter.DATE_FMT, Locale.US).format(d);
} }
/** /**

View File

@ -24,6 +24,7 @@ import java.io.IOException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Collection; import java.util.Collection;
import java.util.Date; import java.util.Date;
import java.util.Locale;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.apache.lucene.index.IndexCommit; import org.apache.lucene.index.IndexCommit;
@ -76,7 +77,7 @@ public class SnapShooter {
String directoryName = null; String directoryName = null;
Lock lock = null; Lock lock = null;
try { try {
SimpleDateFormat fmt = new SimpleDateFormat(DATE_FMT); SimpleDateFormat fmt = new SimpleDateFormat(DATE_FMT, Locale.US);
directoryName = "snapshot." + fmt.format(new Date()); directoryName = "snapshot." + fmt.format(new Date());
lock = lockFactory.makeLock(directoryName + ".lock"); lock = lockFactory.makeLock(directoryName + ".lock");
if (lock.isLocked()) return; if (lock.isLocked()) return;

View File

@ -743,7 +743,7 @@ class JSONWriter extends TextResponseWriter {
// builder's buffer. // builder's buffer.
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
if (cal==null) cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); if (cal==null) cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"), Locale.US);
cal.setTime(val); cal.setTime(val);
int i = cal.get(Calendar.YEAR); int i = cal.get(Calendar.YEAR);

View File

@ -162,7 +162,7 @@ final public class XMLWriter {
// temporary working objects... // temporary working objects...
// be careful not to use these recursively... // be careful not to use these recursively...
private final ArrayList tlst = new ArrayList(); private final ArrayList tlst = new ArrayList();
private final Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); private final Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"), Locale.US);
private final StringBuilder sb = new StringBuilder(); private final StringBuilder sb = new StringBuilder();
public XMLWriter(Writer writer, IndexSchema schema, SolrQueryRequest req, String version) { public XMLWriter(Writer writer, IndexSchema schema, SolrQueryRequest req, String version) {

View File

@ -171,7 +171,7 @@ public class TestTrie extends SolrTestCaseJ4 {
assertQ("Range filter tint:[* to *] must match 10 documents", req("q", "*:*", "fq", "tdate:[* TO *]"), "//*[@numFound='10']"); assertQ("Range filter tint:[* to *] must match 10 documents", req("q", "*:*", "fq", "tdate:[* TO *]"), "//*[@numFound='10']");
// Test date math syntax // Test date math syntax
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US);
format.setTimeZone(TimeZone.getTimeZone("UTC")); format.setTimeZone(TimeZone.getTimeZone("UTC"));
assertU(delQ("*:*")); assertU(delQ("*:*"));
@ -222,7 +222,7 @@ public class TestTrie extends SolrTestCaseJ4 {
checkPrecisionSteps("tdate"); checkPrecisionSteps("tdate");
// For tdate tests // For tdate tests
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US);
format.setTimeZone(TimeZone.getTimeZone("UTC")); format.setTimeZone(TimeZone.getTimeZone("UTC"));
DateMathParser dmp = new DateMathParser(DateField.UTC, Locale.US); DateMathParser dmp = new DateMathParser(DateField.UTC, Locale.US);

View File

@ -24,6 +24,7 @@ import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import java.util.Locale;
import java.util.Random; import java.util.Random;
/** /**
@ -43,7 +44,7 @@ public class TestFaceting extends SolrTestCaseJ4 {
} }
String t(int tnum) { String t(int tnum) {
return String.format("%08d", tnum); return String.format(Locale.US, "%08d", tnum);
} }
void createIndex(int nTerms) { void createIndex(int nTerms) {