From 90ab90d6b9b6bd5b63db0d15bc62d13c4946bdf7 Mon Sep 17 00:00:00 2001 From: Stephan Date: Fri, 21 Dec 2018 13:42:04 +0100 Subject: [PATCH] Fix ExamineComponent crashing on shutdown --- src/Umbraco.Web/Search/ExamineComponent.cs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/Umbraco.Web/Search/ExamineComponent.cs b/src/Umbraco.Web/Search/ExamineComponent.cs index 71061a5cb3..fff8e99aeb 100644 --- a/src/Umbraco.Web/Search/ExamineComponent.cs +++ b/src/Umbraco.Web/Search/ExamineComponent.cs @@ -93,6 +93,11 @@ namespace Umbraco.Web.Search false)); composition.Container.RegisterSingleton, MediaValueSetBuilder>(); composition.Container.RegisterSingleton, MemberValueSetBuilder>(); + + //We want to manage Examine's appdomain shutdown sequence ourselves so first we'll disable Examine's default behavior + //and then we'll use MainDom to control Examine's shutdown - this MUST be done in Compose ie before ExamineManager + //is instantiated, as the value is used during instantiation + ExamineManager.DisableDefaultHostingEnvironmentRegistration(); } internal void Initialize(IRuntimeState runtime, MainDom mainDom, PropertyEditorCollection propertyEditors, @@ -112,10 +117,6 @@ namespace Umbraco.Web.Search _mediaValueSetBuilder = mediaValueSetBuilder; _memberValueSetBuilder = memberValueSetBuilder; - //We want to manage Examine's appdomain shutdown sequence ourselves so first we'll disable Examine's default behavior - //and then we'll use MainDom to control Examine's shutdown - ExamineManager.DisableDefaultHostingEnvironmentRegistration(); - //we want to tell examine to use a different fs lock instead of the default NativeFSFileLock which could cause problems if the appdomain //terminates and in some rare cases would only allow unlocking of the file if IIS is forcefully terminated. Instead we'll rely on the simplefslock //which simply checks the existence of the lock file @@ -203,7 +204,7 @@ namespace Umbraco.Web.Search } } - + /// /// Must be called to each index is unlocked before any indexing occurs @@ -581,7 +582,7 @@ namespace Umbraco.Web.Search } } - + #endregion #region ReIndex/Delete for entity @@ -782,7 +783,7 @@ namespace Umbraco.Web.Search { var strId = id.ToString(CultureInfo.InvariantCulture); foreach (var index in examineComponent._examineManager.Indexes.OfType() - + .Where(x => (keepIfUnpublished && !x.PublishedValuesOnly) || !keepIfUnpublished) .Where(x => x.EnableDefaultEventHandler)) {