SOLR-1916: DIH - fix remaining forbidden apis & remove build-time exclusion

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1411820 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
James Dyer 2012-11-20 19:48:54 +00:00
parent 1f47a886a3
commit 01ffd5b4b4
6 changed files with 24 additions and 17 deletions

View File

@ -249,9 +249,7 @@
<include name="executors.txt" />
</apiFileSet>
<fileset dir="${basedir}/build">
<include name="**/*.class" />
<!-- exclude DIH for now as it is broken with Locales and Encodings: SOLR-1916 -->
<exclude name="contrib/solr-dataimporthandler*/**" />
<include name="**/*.class" />
</fileset>
</forbidden-apis>
</target>

View File

@ -85,7 +85,7 @@ public class MailEntityProcessor extends EntityProcessorBase {
String s = getStringFromContext("fetchMailsSince", null);
if (s != null)
try {
fetchMailsSince = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(s);
fetchMailsSince = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.ROOT).parse(s);
} catch (ParseException e) {
throw new DataImportHandlerException(DataImportHandlerException.SEVERE, "Invalid value for fetchMailSince: " + s, e);
}

View File

@ -22,6 +22,7 @@ import java.io.PrintWriter;
import java.io.StringWriter;
import java.text.MessageFormat;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;
import java.util.Stack;
@ -50,7 +51,7 @@ class DebugLogger {
private static final String LINE = "---------------------------------------------";
private MessageFormat fmt = new MessageFormat(
"----------- row #{0}-------------");
"----------- row #{0}-------------", Locale.ROOT);
boolean enabled = true;

View File

@ -701,24 +701,32 @@ public class DocBuilder {
}
private String findMatchingPkColumn(String pk, Map<String, Object> row) {
if (row.containsKey(pk))
throw new IllegalArgumentException(
String.format("deltaQuery returned a row with null for primary key %s", pk));
if (row.containsKey(pk)) {
throw new IllegalArgumentException(String.format(Locale.ROOT,
"deltaQuery returned a row with null for primary key %s", pk));
}
String resolvedPk = null;
for (String columnName : row.keySet()) {
if (columnName.endsWith("." + pk) || pk.endsWith("." + columnName)) {
if (resolvedPk != null)
throw new IllegalArgumentException(
String.format(
String.format(Locale.ROOT,
"deltaQuery has more than one column (%s and %s) that might resolve to declared primary key pk='%s'",
resolvedPk, columnName, pk));
resolvedPk = columnName;
}
}
if (resolvedPk == null)
if (resolvedPk == null) {
throw new IllegalArgumentException(
String.format("deltaQuery has no column to resolve to declared primary key pk='%s'", pk));
LOG.info(String.format("Resolving deltaQuery column '%s' to match entity's declared pk '%s'", resolvedPk, pk));
String
.format(
Locale.ROOT,
"deltaQuery has no column to resolve to declared primary key pk='%s'",
pk));
}
LOG.info(String.format(Locale.ROOT,
"Resolving deltaQuery column '%s' to match entity's declared pk '%s'",
resolvedPk, pk));
return resolvedPk;
}

View File

@ -247,14 +247,14 @@ public class TestDocBuilder2 extends AbstractDataImportHandlerTestCase {
Map<String, String> params = createMap("baseDir", tmpdir.getAbsolutePath());
createFile(tmpdir, "a.xml", "a.xml".getBytes(), true);
createFile(tmpdir, "b.xml", "b.xml".getBytes(), true);
createFile(tmpdir, "c.props", "c.props".getBytes(), true);
createFile(tmpdir, "a.xml", "a.xml".getBytes("UTF-8"), true);
createFile(tmpdir, "b.xml", "b.xml".getBytes("UTF-8"), true);
createFile(tmpdir, "c.props", "c.props".getBytes("UTF-8"), true);
runFullImport(dataConfigFileList, params);
assertQ(req("*:*"), "//*[@numFound='3']");
// Add a new file after a full index is done
createFile(tmpdir, "t.xml", "t.xml".getBytes(), false);
createFile(tmpdir, "t.xml", "t.xml".getBytes("UTF-8"), false);
runFullImport(dataConfigFileList, params);
// we should find only 1 because by default clean=true is passed
// and this particular import should find only one file t.xml

View File

@ -56,7 +56,7 @@ public class TestSimplePropertiesWriter extends AbstractDIHJdbcTestCase {
@Test
public void testSimplePropertiesWriter() throws Exception {
SimpleDateFormat errMsgFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSSSSS");
SimpleDateFormat errMsgFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSSSSS", Locale.ROOT);
String[] d = {
"{'ts' ''yyyy-MM-dd HH:mm:ss.SSSSSS''}",