Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Loskutov2017-10-05 21:32:53 +0000
committerAndrey Loskutov2017-10-09 12:43:34 +0000
commita53e3f3411e84616ce4f33f8806acd163a230b25 (patch)
treeffc3e79c49e18ed0d5421c9ff336c48764b8c64b
parent320d56ab4590cb50951fe5d7a9501dcf45dc3e5c (diff)
downloadeclipse.platform.ua-a53e3f3411e84616ce4f33f8806acd163a230b25.tar.gz
eclipse.platform.ua-a53e3f3411e84616ce4f33f8806acd163a230b25.tar.xz
eclipse.platform.ua-a53e3f3411e84616ce4f33f8806acd163a230b25.zip
Make sure the index writer is opened if we are going to delete invalid entries. Change-Id: I9736ed4b4f038867aab5dafabbbb51d3ad3b874c Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
-rw-r--r--org.eclipse.help.base/src/org/eclipse/help/internal/search/IndexingOperation.java59
-rw-r--r--org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchIndex.java5
2 files changed, 35 insertions, 29 deletions
diff --git a/org.eclipse.help.base/src/org/eclipse/help/internal/search/IndexingOperation.java b/org.eclipse.help.base/src/org/eclipse/help/internal/search/IndexingOperation.java
index ec744ffa9..87bac9c9b 100644
--- a/org.eclipse.help.base/src/org/eclipse/help/internal/search/IndexingOperation.java
+++ b/org.eclipse.help.base/src/org/eclipse/help/internal/search/IndexingOperation.java
@@ -195,44 +195,45 @@ class IndexingOperation {
*/
private void removeNewDocuments(IProgressMonitor pm, Map<String, String[]> docsToDelete)
throws IndexingException {
+ if (docsToDelete.size() == 0) {
+ return;
+ }
pm = new LazyProgressMonitor(pm);
pm.beginTask("", docsToDelete.size()); //$NON-NLS-1$
checkCancelled(pm);
Set<String> keysToDelete = docsToDelete.keySet();
- if (keysToDelete.size() > 0) {
- if (!index.beginRemoveDuplicatesBatch()) {
- throw new IndexingException();
+ if (!index.beginRemoveDuplicatesBatch()) {
+ throw new IndexingException();
+ }
+ MultiStatus multiStatus = null;
+ for (Iterator<String> it = keysToDelete.iterator(); it.hasNext();) {
+ String href = it.next();
+ String[] indexIds = docsToDelete.get(href);
+ if (indexIds == null) {
+ // delete all copies
+ index.removeDocument(href);
+ continue;
}
- MultiStatus multiStatus = null;
- for (Iterator<String> it = keysToDelete.iterator(); it.hasNext();) {
- String href = it.next();
- String[] indexIds = docsToDelete.get(href);
- if (indexIds == null) {
- // delete all copies
- index.removeDocument(href);
- continue;
- }
- IStatus status = index.removeDuplicates(href, indexIds);
- if (status.getCode() != IStatus.OK) {
- if (multiStatus == null) {
- multiStatus = new MultiStatus(
- HelpBasePlugin.PLUGIN_ID,
- IStatus.WARNING,
- "Some help documents could not removed from index.", //$NON-NLS-1$
- null);
- }
- multiStatus.add(status);
- }
- checkCancelled(pm);
- pm.worked(1);
- if (multiStatus != null) {
- HelpBasePlugin.logStatus(multiStatus);
+ IStatus status = index.removeDuplicates(href, indexIds);
+ if (status.getCode() != IStatus.OK) {
+ if (multiStatus == null) {
+ multiStatus = new MultiStatus(
+ HelpBasePlugin.PLUGIN_ID,
+ IStatus.WARNING,
+ "Some help documents could not removed from index.", //$NON-NLS-1$
+ null);
}
+ multiStatus.add(status);
}
- if (!index.endRemoveDuplicatesBatch()) {
- throw new IndexingException();
+ checkCancelled(pm);
+ pm.worked(1);
+ if (multiStatus != null) {
+ HelpBasePlugin.logStatus(multiStatus);
}
}
+ if (!index.endRemoveDuplicatesBatch()) {
+ throw new IndexingException();
+ }
pm.done();
}
diff --git a/org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchIndex.java b/org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchIndex.java
index bd8de4239..74d17d06c 100644
--- a/org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchIndex.java
+++ b/org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchIndex.java
@@ -352,6 +352,9 @@ public class SearchIndex implements IHelpSearchIndex {
ir.close();
}
ir = DirectoryReader.open(luceneDirectory);
+ if (iw == null) {
+ return beginDeleteBatch();
+ }
return true;
} catch (IOException e) {
HelpBasePlugin.logError("Exception occurred in search indexing at beginDeleteBatch.", e); //$NON-NLS-1$
@@ -458,6 +461,8 @@ public class SearchIndex implements IHelpSearchIndex {
return false;
ir.close();
ir = null;
+ iw.close();
+ iw = null;
// save the update info:
// - all the docs
// - plugins (and their version) that were indexed

Back to the top