From 38108ad8106faa2f443a7bafc0f58ae78567b682 Mon Sep 17 00:00:00 2001 From: Shinsuke Sugaya Date: Thu, 25 Jan 2024 15:36:47 +0900 Subject: [PATCH] fix #2800 Handle Exceptions in Suggester Instance Initialization --- .../codelibs/fess/helper/SuggestHelper.java | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/main/java/org/codelibs/fess/helper/SuggestHelper.java b/src/main/java/org/codelibs/fess/helper/SuggestHelper.java index 091fa933c..713e1db05 100644 --- a/src/main/java/org/codelibs/fess/helper/SuggestHelper.java +++ b/src/main/java/org/codelibs/fess/helper/SuggestHelper.java @@ -109,19 +109,22 @@ public void init() { settingsBuilder.indicesTimeout(fessConfig.getIndexIndicesTimeout()); settingsBuilder.searchTimeout(fessConfig.getIndexSearchTimeout()); suggester = Suggester.builder().settings(settingsBuilder).build(searchEngineClient, fessConfig.getIndexDocumentSuggestIndex()); - suggester.settings().array().delete(SuggestSettings.DefaultKeys.SUPPORTED_FIELDS); - split(fessConfig.getSuggestFieldIndexContents(), ",").of(stream -> stream.filter(StringUtil::isNotBlank).forEach(field -> { - try { - suggester.settings().array().add(SuggestSettings.DefaultKeys.SUPPORTED_FIELDS, field); - } catch (final SuggestSettingsException e) { - logger.warn("Failed to add {}", field, e); - } - })); - suggester.createIndexIfNothing(); - if (ComponentUtil.hasPopularWordHelper()) { popularWordHelper = ComponentUtil.getPopularWordHelper(); } + try { + suggester.settings().array().delete(SuggestSettings.DefaultKeys.SUPPORTED_FIELDS); + split(fessConfig.getSuggestFieldIndexContents(), ",").of(stream -> stream.filter(StringUtil::isNotBlank).forEach(field -> { + try { + suggester.settings().array().add(SuggestSettings.DefaultKeys.SUPPORTED_FIELDS, field); + } catch (final SuggestSettingsException e) { + logger.warn("Failed to add {}", field, e); + } + })); + suggester.createIndexIfNothing(); + } catch (final Exception e) { + logger.warn("Failed to initialize Suggester.", e); + } } public Suggester suggester() {