From 36faff6917b3bae915bc8690b939c23bac4dcee3 Mon Sep 17 00:00:00 2001 From: Arkadiusz Biel Date: Sat, 26 Feb 2022 22:14:58 +0000 Subject: [PATCH] add null check for case when index is not implementing LuceneDirectoryIndexOptions --- .../LuceneIndexDiagnostics.cs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Umbraco.Examine.Lucene/LuceneIndexDiagnostics.cs b/src/Umbraco.Examine.Lucene/LuceneIndexDiagnostics.cs index ba3945c6e5..33230a296d 100644 --- a/src/Umbraco.Examine.Lucene/LuceneIndexDiagnostics.cs +++ b/src/Umbraco.Examine.Lucene/LuceneIndexDiagnostics.cs @@ -27,7 +27,11 @@ namespace Umbraco.Cms.Infrastructure.Examine IOptionsMonitor indexOptions) { _hostingEnvironment = hostingEnvironment; - _indexOptions = indexOptions.Get(index.Name); + if (indexOptions != null) + { + _indexOptions = indexOptions.Get(index.Name); + + } Index = index; Logger = logger; } @@ -35,7 +39,7 @@ namespace Umbraco.Cms.Infrastructure.Examine public LuceneIndex Index { get; } public ILogger Logger { get; } - + public Attempt IsHealthy() { @@ -72,12 +76,12 @@ namespace Umbraco.Cms.Infrastructure.Examine { d[nameof(LuceneDirectoryIndexOptions.DirectoryFactory)] = _indexOptions.DirectoryFactory.GetType(); } - + if (_indexOptions.IndexDeletionPolicy != null) { d[nameof(LuceneDirectoryIndexOptions.IndexDeletionPolicy)] = _indexOptions.IndexDeletionPolicy.GetType(); - } - + } + } return d;