Skip to content

Apache Lucene open-source search software

LUCENE-5347: Upgrade forbidden-apis checker to version 1.4. Fix Zookeeper bug with default encoding.

Uwe Schindler0971bc8f219b
diff --git a/dev-tools/maven/pom.xml.template b/dev-tools/maven/pom.xml.template
index 81131dd817f..5539f18857e 100644
--- a/dev-tools/maven/pom.xml.template
+++ b/dev-tools/maven/pom.xml.template
@@ -159,7 +159,7 @@
<plugin>
<groupId>de.thetaphi</groupId>
<artifactId>forbiddenapis</artifactId>
- <version>1.3</version>
+ <version>1.4</version>
<configuration>
<!--
This is the default setting, we don't support too new Java versions.
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 027f70a106a..6a4af18a138 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -78,6 +78,9 @@ Build
* LUCENE-5322: Clean up / simplify Maven-related Ant targets.
(Steve Rowe)
+* LUCENE-5347: Upgrade forbidden-apis checker to version 1.4.
+ (Uwe Schindler)
+
======================= Lucene 4.6.0 =======================
New Features
diff --git a/lucene/common-build.xml b/lucene/common-build.xml
index 300c59f7e21..fc05164bf04 100644
--- a/lucene/common-build.xml
+++ b/lucene/common-build.xml
@@ -2182,7 +2182,7 @@ ${ant.project.name}.test.dependencies=${test.classpath.list}
<property name="forbidden-sysout-excludes" value=""/>
<target name="-install-forbidden-apis" unless="forbidden-apis.loaded" depends="ivy-availability-check,ivy-configure">
- <ivy:cachepath organisation="de.thetaphi" module="forbiddenapis" revision="1.3"
+ <ivy:cachepath organisation="de.thetaphi" module="forbiddenapis" revision="1.4"
inline="true" conf="default" transitive="true" pathid="forbidden-apis.classpath"/>
<taskdef name="forbidden-apis" classname="de.thetaphi.forbiddenapis.AntTask" classpathref="forbidden-apis.classpath"/>
<property name="forbidden-apis.loaded" value="true"/>
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 11c754cf15d..4a1f5dc4e6a 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -130,6 +130,11 @@ Bug Fixes
* SOLR-4709: The core reload after replication if config files have changed
can fail due to a race condition. (Mark Miller, Hossman))
+* LUCENE-5347: Fixed Solr's Zookeeper Client to copy files to Zookeeper using
+ binary transfer. Previously data was read with default encoding and stored
+ in zookeeper as UTF-8. This bug was found after upgrading to forbidden-apis
+ 1.4. (Uwe Schindler)
+
Optimizations
----------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/ShowFileRequestHandler.java b/solr/core/src/java/org/apache/solr/handler/admin/ShowFileRequestHandler.java
index 72e8099f69a..743deb5b917 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/ShowFileRequestHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/ShowFileRequestHandler.java
@@ -423,7 +423,7 @@ public class ShowFileRequestHandler extends RequestHandlerBase
File home = null;
try {
home = new File(FileUtils.getTempDirectory(), "SOLR_5459"); // Unlikely to name a core or collection this!
- FileUtils.writeStringToFile(new File(home, "solr.xml"), "<solr></solr>"); // Use auto-discovery
+ FileUtils.writeStringToFile(new File(home, "solr.xml"), "<solr></solr>", "UTF-8"); // Use auto-discovery
File coll = new File(home, "SOLR_5459");
SolrCore core = req.getCore();
@@ -447,7 +447,7 @@ public class ShowFileRequestHandler extends RequestHandlerBase
new File(coll, "conf"));
}
- FileUtils.writeStringToFile(new File(coll, "core.properties"), "name=SOLR_5459");
+ FileUtils.writeStringToFile(new File(coll, "core.properties"), "name=SOLR_5459", "UTF-8");
FileUtils.copyInputStreamToFile(stream.getStream(),
new File(new File(coll, "conf"), req.getParams().get("file", null)));
diff --git a/solr/core/src/test/org/apache/solr/AnalysisAfterCoreReloadTest.java b/solr/core/src/test/org/apache/solr/AnalysisAfterCoreReloadTest.java
index 0e1e7988b05..41a691f7605 100644
--- a/solr/core/src/test/org/apache/solr/AnalysisAfterCoreReloadTest.java
+++ b/solr/core/src/test/org/apache/solr/AnalysisAfterCoreReloadTest.java
@@ -121,7 +121,7 @@ public class AnalysisAfterCoreReloadTest extends SolrTestCaseJ4 {
String configDir = core.getResourceLoader().getConfigDir();
FileUtils.moveFile(new File(configDir, "stopwords.txt"), new File(configDir, "stopwords.txt.bak"));
File file = new File(configDir, "stopwords.txt");
- FileUtils.writeStringToFile(file, stopwords);
+ FileUtils.writeStringToFile(file, stopwords, "UTF-8");
} finally {
core.close();
diff --git a/solr/core/src/test/org/apache/solr/core/TestLazyCores.java b/solr/core/src/test/org/apache/solr/core/TestLazyCores.java
index 6624a44e96a..53f414e33ca 100644
--- a/solr/core/src/test/org/apache/solr/core/TestLazyCores.java
+++ b/solr/core/src/test/org/apache/solr/core/TestLazyCores.java
@@ -579,7 +579,7 @@ public class TestLazyCores extends SolrTestCaseJ4 {
System.getProperty("line.separator") + "transient=true" +
System.getProperty("line.separator") + "loadOnStartup=true", Charsets.UTF_8.toString());
- FileUtils.writeStringToFile(new File(subHome, "solrconfig.snippet.randomindexconfig.xml"), rand_snip);
+ FileUtils.writeStringToFile(new File(subHome, "solrconfig.snippet.randomindexconfig.xml"), rand_snip, Charsets.UTF_8.toString());
FileUtils.writeStringToFile(new File(subHome, "solrconfig.xml"), config, Charsets.UTF_8.toString());
diff --git a/solr/core/src/test/org/apache/solr/handler/PingRequestHandlerTest.java b/solr/core/src/test/org/apache/solr/handler/PingRequestHandlerTest.java
index d06783fc5f8..8cf4c02b292 100644
--- a/solr/core/src/test/org/apache/solr/handler/PingRequestHandlerTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/PingRequestHandlerTest.java
@@ -100,7 +100,7 @@ public class PingRequestHandlerTest extends SolrTestCaseJ4 {
makeRequest(handler, req("action", "enable"));
assertTrue(healthcheckFile.exists());
- assertNotNull(FileUtils.readFileToString(healthcheckFile), "UTF-8");
+ assertNotNull(FileUtils.readFileToString(healthcheckFile, "UTF-8"));
// now verify that the handler response with success
diff --git a/solr/core/src/test/org/apache/solr/schema/ModifyConfFileTest.java b/solr/core/src/test/org/apache/solr/schema/ModifyConfFileTest.java
index c6698b353d7..c763190be19 100644
--- a/solr/core/src/test/org/apache/solr/schema/ModifyConfFileTest.java
+++ b/solr/core/src/test/org/apache/solr/schema/ModifyConfFileTest.java
@@ -94,7 +94,7 @@ public class ModifyConfFileTest extends SolrTestCaseJ4 {
assertTrue("Schema should have caused core reload to fail!",
rsp.getException().getMessage().indexOf("SAXParseException") != -1);
- String contents = FileUtils.readFileToString(new File(core.getCoreDescriptor().getInstanceDir(), "conf/schema.xml"));
+ String contents = FileUtils.readFileToString(new File(core.getCoreDescriptor().getInstanceDir(), "conf/schema.xml"), Charsets.UTF_8.toString());
assertFalse("Schema contents should NOT have changed!", contents.contains("Testing rewrite of schema.xml file."));
streams.add(new ContentStreamBase.StringStream("This should barf"));
@@ -110,7 +110,7 @@ public class ModifyConfFileTest extends SolrTestCaseJ4 {
locReq.setContentStreams(streams);
core.execute(handler, locReq, rsp);
contents = FileUtils.readFileToString(new File(core.getCoreDescriptor().getInstanceDir(),
- "conf/velocity/test.vm"));
+ "conf/velocity/test.vm"), Charsets.UTF_8.toString());
assertEquals("Schema contents should have changed!", "Some bogus stuff for a test.", contents);
streams.clear();
diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZkClient.java b/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZkClient.java
index f9a1890e4ef..9c5dada556b 100644
--- a/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZkClient.java
+++ b/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZkClient.java
@@ -481,8 +481,8 @@ public class SolrZkClient {
log.info("Write to ZooKeepeer " + file.getAbsolutePath() + " to " + path);
}
- String data = FileUtils.readFileToString(file);
- return setData(path, data.getBytes("UTF-8"), retryOnConnLoss);
+ byte[] data = FileUtils.readFileToByteArray(file);
+ return setData(path, data, retryOnConnLoss);
}
/**