Apache Lucene open-source search software
LUCENE-10024: Catch NoSuchFileException when opening index directory
Michael Wechner489ba3e4f902
diff --git a/lucene/luke/src/java/org/apache/lucene/luke/app/IndexHandler.java b/lucene/luke/src/java/org/apache/lucene/luke/app/IndexHandler.javaindex f3fc635872b..4f1ee8feaab 100644--- a/lucene/luke/src/java/org/apache/lucene/luke/app/IndexHandler.java+++ b/lucene/luke/src/java/org/apache/lucene/luke/app/IndexHandler.java@@ -18,6 +18,7 @@package org.apache.lucene.luke.app;import java.lang.invoke.MethodHandles;+import java.nio.file.NoSuchFileException;import java.util.Objects;import org.apache.logging.log4j.Logger;import org.apache.lucene.index.IndexReader;@@ -71,6 +72,12 @@ public final class IndexHandler extends AbstractHandler<IndexObserver> {IndexReader reader;try {reader = IndexUtils.openIndex(indexPath, dirImpl);+ } catch (NoSuchFileException e) {+ log.error("Error opening index", e);+ throw new LukeException(+ MessageUtils.getLocalizedMessage(+ "openindex.message.index_path_does_not_exist", indexPath),+ e);} catch (Exception e) {log.error("Error opening index", e);throw new LukeException(diff --git a/lucene/luke/src/resources/org/apache/lucene/luke/app/desktop/messages/messages.properties b/lucene/luke/src/resources/org/apache/lucene/luke/app/desktop/messages/messages.propertiesindex f9c8c45a0f4..30b43cf18b7 100644--- a/lucene/luke/src/resources/org/apache/lucene/luke/app/desktop/messages/messages.properties+++ b/lucene/luke/src/resources/org/apache/lucene/luke/app/desktop/messages/messages.properties@@ -71,6 +71,7 @@ openindex.radio.keep_only_last_commit=Keep only last commit pointopenindex.radio.keep_all_commits=Keep all commit pointsopenindex.message.index_path_not_selected=Please choose index path.openindex.message.index_path_invalid=Cannot open index path {0}. Not a valid lucene index directory or corrupted?+openindex.message.index_path_does_not_exist=Cannot open index path {0}. No such directory!openindex.message.index_opened=Index successfully opened.openindex.message.index_opened_ro=Index successfully opened. (read-only)openindex.message.index_opened_multi=Index successfully opened. (multi-reader)@@ -289,4 +290,4 @@ help.fieldtype.SortedSetDocValuesField=Field that stores a set of per-document Bhelp.fieldtype.NumericDocValuesField=Field that stores a per-document long value for scoring, sorting or value retrieval.\nIf you also need to store the value, you should add a separate StoredField instance.\nDoubles or Floats will be encoded with org.apache.lucene.util.NumericUtils.\n\n(Example Values)\n- 42\n- 3.14help.fieldtype.SortedNumericDocValuesField=Field that stores a per-document long values for scoring, sorting or value retrieval.\nIf you also need to store the value, you should add a separate StoredField instance.\nDoubles or Floats will be encoded with org.apache.lucene.util.NumericUtils.\n\n(Example Values)\n- 42\n- 3.14help.fieldtype.StoredField=A field whose value is stored.\n\n(Example Values)\n- Hello Lucene!-help.fieldtype.Field=Expert: directly create a field for a document. Most users should use one of the sugar subclasses above.\ No newline at end of file+help.fieldtype.Field=Expert: directly create a field for a document. Most users should use one of the sugar subclasses above.