summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJames Moger <james.moger@gitblit.com>2012-03-15 19:51:16 -0400
committerJames Moger <james.moger@gitblit.com>2012-03-15 19:51:16 -0400
commite6637cd48c50aa5ebbc01e7826b835b75bd92a87 (patch)
tree1e80549e04904346723084ce434d6d77ad1f353a /src
parent905d31391cb6a808605d9f5b58a8d30274c01e1a (diff)
downloadgitblit-e6637cd48c50aa5ebbc01e7826b835b75bd92a87.tar.gz
gitblit-e6637cd48c50aa5ebbc01e7826b835b75bd92a87.zip
Close the Lucene index writer/searcher on a repository rename or delete
Diffstat (limited to 'src')
-rw-r--r--src/com/gitblit/GitBlit.java3
-rw-r--r--src/com/gitblit/LuceneExecutor.java25
2 files changed, 28 insertions, 0 deletions
diff --git a/src/com/gitblit/GitBlit.java b/src/com/gitblit/GitBlit.java
index 3bda06fb..15b69ec0 100644
--- a/src/com/gitblit/GitBlit.java
+++ b/src/com/gitblit/GitBlit.java
@@ -871,6 +871,9 @@ public class GitBlit implements ServletContextListener {
repository.close();
}
}
+
+ // close any open index writer/searcher in the Lucene executor
+ luceneExecutor.close(repositoryName);
}
/**
diff --git a/src/com/gitblit/LuceneExecutor.java b/src/com/gitblit/LuceneExecutor.java
index 3b8c2b4f..0b90b74c 100644
--- a/src/com/gitblit/LuceneExecutor.java
+++ b/src/com/gitblit/LuceneExecutor.java
@@ -233,6 +233,31 @@ public class LuceneExecutor implements Runnable {
logger.error(MessageFormat.format("Lucene indexing failure for {0}", name), t);
}
}
+
+ /**
+ * Close the writer/searcher objects for a repository.
+ *
+ * @param repositoryName
+ */
+ public void close(String repositoryName) {
+ try {
+ IndexWriter writer = writers.remove(repositoryName);
+ if (writer != null) {
+ writer.close();
+ }
+ } catch (Exception e) {
+ logger.error("Failed to close index writer for " + repositoryName, e);
+ }
+
+ try {
+ IndexSearcher searcher = searchers.remove(repositoryName);
+ if (searcher != null) {
+ searcher.close();
+ }
+ } catch (Exception e) {
+ logger.error("Failed to close index searcher for " + repositoryName, e);
+ }
+ }
/**
* Close all Lucene indexers.