From 06d1d4878374ccd6a5616cf6903770d4f5785278 Mon Sep 17 00:00:00 2001 From: Paul Stupka Date: Tue, 13 Dec 2016 16:21:36 +0200 Subject: [PATCH] LanguageFallbackItemSwitcher context lost when computed index fields are added in parallel --- .../LuceneProvider/LuceneDocumentBuilder.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Sitecore.Support.96931/ContentSearch/LuceneProvider/LuceneDocumentBuilder.cs b/src/Sitecore.Support.96931/ContentSearch/LuceneProvider/LuceneDocumentBuilder.cs index 8587076..a10ef10 100644 --- a/src/Sitecore.Support.96931/ContentSearch/LuceneProvider/LuceneDocumentBuilder.cs +++ b/src/Sitecore.Support.96931/ContentSearch/LuceneProvider/LuceneDocumentBuilder.cs @@ -23,15 +23,19 @@ public LuceneDocumentBuilder(IIndexable indexable, IProviderUpdateContext contex protected override void AddComputedIndexFieldsInParallel() { ConcurrentQueue exceptions = new ConcurrentQueue(); + var needEnterLanguageFallbackItemSwitcher = LanguageFallbackItemSwitcher.CurrentValue; Parallel.ForEach(base.Options.ComputedIndexFields, base.ParallelOptions, delegate (IComputedIndexField computedIndexField, ParallelLoopState parallelLoopState) { object fieldValue; try { - using (new LanguageFallbackFieldSwitcher(this.Index.EnableFieldLanguageFallback)) + using (new LanguageFallbackItemSwitcher(needEnterLanguageFallbackItemSwitcher)) { - fieldValue = computedIndexField.ComputeFieldValue(this.Indexable); - } + using (new LanguageFallbackFieldSwitcher(this.Index.EnableFieldLanguageFallback)) + { + fieldValue = computedIndexField.ComputeFieldValue(this.Indexable); + } + } } catch (Exception ex) {