Skip to content

Apache Lucene open-source search software

SOLR-5133: HdfsUpdateLog can fail to close a FileSystem instance if init is called more than once.

Mark Robert Miller2e12d5635e6b
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index b9f95e895e3..9d6b54a40cc 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -116,6 +116,10 @@ Bug Fixes
* SOLR-5119: Managed schema problems after adding fields via Schema Rest API.
(Nils Kübler, Steve Rowe)
+
+* SOLR-5133: HdfsUpdateLog can fail to close a FileSystem instance if init
+ is called more than once. (Mark Miller)
+
Optimizations
----------------------
diff --git a/solr/core/src/java/org/apache/solr/update/HdfsUpdateLog.java b/solr/core/src/java/org/apache/solr/update/HdfsUpdateLog.java
index e209c85be74..097a7c4d682 100644
--- a/solr/core/src/java/org/apache/solr/update/HdfsUpdateLog.java
+++ b/solr/core/src/java/org/apache/solr/update/HdfsUpdateLog.java
@@ -42,22 +42,18 @@ import org.apache.solr.util.IOUtils;
/** @lucene.experimental */
public class HdfsUpdateLog extends UpdateLog {
- private FileSystem fs;
- private Path tlogDir;
- private String confDir;
+ private volatile FileSystem fs;
+ private volatile Path tlogDir;
+ private final String confDir;
public HdfsUpdateLog() {
-
+ this.confDir = null;
}
public HdfsUpdateLog(String confDir) {
this.confDir = confDir;
}
- public FileSystem getFs() {
- return fs;
- }
-
// HACK
// while waiting for HDFS-3107, instead of quickly
// dropping, we slowly apply
@@ -117,6 +113,14 @@ public class HdfsUpdateLog extends UpdateLog {
}
}
+ try {
+ if (fs != null) {
+ fs.close();
+ }
+ } catch (IOException e) {
+ throw new SolrException(ErrorCode.SERVER_ERROR, e);
+ }
+
try {
fs = FileSystem.newInstance(new Path(dataDir).toUri(), getConf());
} catch (IOException e) {