Skip to content

Apache Lucene open-source search software

LUCENE-4199: add default local DecimalFormat ctors

Robert Muir413852888961
diff --git a/lucene/core/src/test/org/apache/lucene/search/TestBooleanMinShouldMatch.java b/lucene/core/src/test/org/apache/lucene/search/TestBooleanMinShouldMatch.java
index 7f0288728a4..8cfe47bf183 100644
--- a/lucene/core/src/test/org/apache/lucene/search/TestBooleanMinShouldMatch.java
+++ b/lucene/core/src/test/org/apache/lucene/search/TestBooleanMinShouldMatch.java
@@ -28,6 +28,8 @@ import org.junit.AfterClass;
import org.junit.BeforeClass;
import java.text.DecimalFormat;
+import java.text.DecimalFormatSymbols;
+import java.util.Locale;
import java.util.Random;
/** Test that BooleanQuery.setMinimumNumberShouldMatch works.
@@ -377,7 +379,7 @@ public class TestBooleanMinShouldMatch extends LuceneTestCase {
System.err.println("------- " + test + " -------");
- DecimalFormat f = new DecimalFormat("0.000000");
+ DecimalFormat f = new DecimalFormat("0.000000", DecimalFormatSymbols.getInstance(Locale.ROOT));
for (int i = 0; i < h.length; i++) {
Document d = searcher.doc(h[i].doc);
diff --git a/lucene/core/src/test/org/apache/lucene/search/TestDisjunctionMaxQuery.java b/lucene/core/src/test/org/apache/lucene/search/TestDisjunctionMaxQuery.java
index a51f93ce96d..661a7ad2262 100644
--- a/lucene/core/src/test/org/apache/lucene/search/TestDisjunctionMaxQuery.java
+++ b/lucene/core/src/test/org/apache/lucene/search/TestDisjunctionMaxQuery.java
@@ -35,6 +35,8 @@ import org.apache.lucene.search.similarities.Similarity;
import org.apache.lucene.store.Directory;
import java.text.DecimalFormat;
+import java.text.DecimalFormatSymbols;
+import java.util.Locale;
import java.io.IOException;
/**
@@ -485,7 +487,7 @@ public class TestDisjunctionMaxQuery extends LuceneTestCase {
System.err.println("------- " + test + " -------");
- DecimalFormat f = new DecimalFormat("0.000000000");
+ DecimalFormat f = new DecimalFormat("0.000000000", DecimalFormatSymbols.getInstance(Locale.ROOT));
for (int i = 0; i < h.length; i++) {
Document d = searcher.doc(h[i].doc);
diff --git a/lucene/misc/src/java/org/apache/lucene/index/IndexSplitter.java b/lucene/misc/src/java/org/apache/lucene/index/IndexSplitter.java
index 31fa60d5871..0f0977c3e88 100644
--- a/lucene/misc/src/java/org/apache/lucene/index/IndexSplitter.java
+++ b/lucene/misc/src/java/org/apache/lucene/index/IndexSplitter.java
@@ -23,9 +23,11 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.text.DecimalFormat;
+import java.text.DecimalFormatSymbols;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
+import java.util.Locale;
import org.apache.lucene.store.FSDirectory;
@@ -97,7 +99,7 @@ public class IndexSplitter {
}
public void listSegments() throws IOException {
- DecimalFormat formatter = new DecimalFormat("###,###.###");
+ DecimalFormat formatter = new DecimalFormat("###,###.###", DecimalFormatSymbols.getInstance(Locale.ROOT));
for (int x = 0; x < infos.size(); x++) {
SegmentInfoPerCommit info = infos.info(x);
String sizeStr = formatter.format(info.sizeInBytes());
diff --git a/lucene/misc/src/test/org/apache/lucene/index/TestPKIndexSplitter.java b/lucene/misc/src/test/org/apache/lucene/index/TestPKIndexSplitter.java
index 1f0e68b1db5..b1878fb8c23 100644
--- a/lucene/misc/src/test/org/apache/lucene/index/TestPKIndexSplitter.java
+++ b/lucene/misc/src/test/org/apache/lucene/index/TestPKIndexSplitter.java
@@ -18,7 +18,9 @@ package org.apache.lucene.index;
*/
import java.text.DecimalFormat;
+import java.text.DecimalFormatSymbols;
import java.text.NumberFormat;
+import java.util.Locale;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.analysis.MockTokenizer;
@@ -32,7 +34,7 @@ import org.apache.lucene.util.LuceneTestCase;
public class TestPKIndexSplitter extends LuceneTestCase {
public void testSplit() throws Exception {
- NumberFormat format = new DecimalFormat("000000000");
+ NumberFormat format = new DecimalFormat("000000000", DecimalFormatSymbols.getInstance(Locale.ROOT));
Directory dir = newDirectory();
IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer(random(), MockTokenizer.WHITESPACE, false))
diff --git a/lucene/tools/forbiddenApis/jdk.txt b/lucene/tools/forbiddenApis/jdk.txt
index c57df9341f1..abcd8e1bc3d 100644
--- a/lucene/tools/forbiddenApis/jdk.txt
+++ b/lucene/tools/forbiddenApis/jdk.txt
@@ -42,6 +42,8 @@ java.text.DateFormat#getDateTimeInstance(int,int)
java.text.DateFormat#getInstance()
java.text.DateFormatSymbols#<init>()
java.text.DateFormatSymbols#getInstance()
+java.text.DecimalFormat#<init>()
+java.text.DecimalFormat#<init>(java.lang.String)
java.text.DecimalFormatSymbols#<init>()
java.text.DecimalFormatSymbols#getInstance()
java.text.MessageFormat#<init>(java.lang.String)
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/SystemInfoHandler.java b/solr/core/src/java/org/apache/solr/handler/admin/SystemInfoHandler.java
index faba839379f..c1fff7f601d 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/SystemInfoHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/SystemInfoHandler.java
@@ -28,6 +28,7 @@ import java.net.InetAddress;
import java.net.UnknownHostException;
import java.nio.charset.Charset;
import java.text.DecimalFormat;
+import java.text.DecimalFormatSymbols;
import java.util.Date;
import java.util.Locale;
@@ -210,7 +211,7 @@ public class SystemInfoHandler extends RequestHandlerBase
jvm.add( "processors", runtime.availableProcessors() );
// not thread safe, but could be thread local
- DecimalFormat df = new DecimalFormat("#.#");
+ DecimalFormat df = new DecimalFormat("#.#", DecimalFormatSymbols.getInstance(Locale.ROOT));
SimpleOrderedMap<Object> mem = new SimpleOrderedMap<Object>();
SimpleOrderedMap<Object> raw = new SimpleOrderedMap<Object>();