diff options
author | Andrey Loskutov | 2017-10-05 21:32:53 +0000 |
---|---|---|
committer | Andrey Loskutov | 2017-10-09 12:43:34 +0000 |
commit | a53e3f3411e84616ce4f33f8806acd163a230b25 (patch) | |
tree | ffc3e79c49e18ed0d5421c9ff336c48764b8c64b | |
parent | 320d56ab4590cb50951fe5d7a9501dcf45dc3e5c (diff) | |
download | eclipse.platform.ua-a53e3f3411e84616ce4f33f8806acd163a230b25.tar.gz eclipse.platform.ua-a53e3f3411e84616ce4f33f8806acd163a230b25.tar.xz eclipse.platform.ua-a53e3f3411e84616ce4f33f8806acd163a230b25.zip |
Bug 509819 - NPE in SearchIndex.removeDocumentS4_8_0_M3aS4_8_0_M3I20171108-2000I20171107-2000I20171106-2000I20171106-0630I20171105-2000I20171104-2025I20171104-1500I20171103-2000I20171103-1105I20171103-0715I20171103-0405I20171102-2000I20171101-2000I20171031-2000I20171030-2000I20171030-0400I20171029-2000I20171028-1500I20171027-2340I20171027-2000I20171025-2000I20171025-0800I20171024-2000I20171024-0800I20171023-2000I20171023-0800I20171022-2000I20171022-0800I20171021-1500I20171020-2000I20171019-2000I20171018-2000I20171017-2000I20171017-0515I20171016-2000I20171015-2000I20171015-0655I20171014-1500I20171013-2000I20171012-2000
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.java | 59 | ||||
-rw-r--r-- | org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchIndex.java | 5 |
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 |