ZEPPELIN-501: fix NPE on double-delete

This commit is contained in:
Alexander Bezzubov 2015-12-23 11:49:53 +09:00
parent d2b44ac955
commit cf44b1f8b1
2 changed files with 12 additions and 0 deletions

View file

@ -302,6 +302,11 @@ public class SearchService {
* Deletes all docs no given Note from index
*/
public void deleteIndexDocs(Note note) {
if (null == note) {
LOG.error("Trying to delete note by reference to NULL");
return;
}
LOG.debug("Deleting note {}, out of: {}", note.getId(), writer.numDocs());
try {
writer.deleteDocuments(new WildcardQuery(new Term(ID_FIELD, note.getId() + "*")));

View file

@ -134,6 +134,13 @@ public class SearchServiceTest {
assertThat(results).isNotEmpty();
}
@Test public void canDeleteNull() throws IOException {
//give
// looks like a bug in web UI: it tries to delete a note twice (after it has just been deleted)
//when
notebookIndex.deleteIndexDocs(null);
}
@Test public void canDeleteFromIndex() throws IOException {
//given
Note note1 = newNoteWithParapgraph("Notebook1", "test");