diff --git a/src/Umbraco.Web/WebApi/AngularJsonMediaTypeFormatter.cs b/src/Umbraco.Web/WebApi/AngularJsonMediaTypeFormatter.cs index 995d2a97ca..81a8f84772 100644 --- a/src/Umbraco.Web/WebApi/AngularJsonMediaTypeFormatter.cs +++ b/src/Umbraco.Web/WebApi/AngularJsonMediaTypeFormatter.cs @@ -7,6 +7,7 @@ using System.Net.Http; using System.Net.Http.Formatting; using System.Text; using System.Threading.Tasks; +using Umbraco.Core.Logging; namespace Umbraco.Web.WebApi { @@ -32,8 +33,16 @@ namespace Umbraco.Web.WebApi using (var memStream = new MemoryStream()) { - //Let the base class do all the processing using our custom stream - await base.WriteToStreamAsync(type, value, memStream, content, transportContext); + try + { + //Let the base class do all the processing using our custom stream + await base.WriteToStreamAsync(type, value, memStream, content, transportContext); + } + catch (Exception ex) + { + LogHelper.Error("An error occurred writing to the output stream", ex); + throw; + } memStream.Flush(); memStream.Position = 0; diff --git a/src/umbraco.cms/businesslogic/macro/MacroEngineFactory.cs b/src/umbraco.cms/businesslogic/macro/MacroEngineFactory.cs index c257f603d7..e73dbaa73f 100644 --- a/src/umbraco.cms/businesslogic/macro/MacroEngineFactory.cs +++ b/src/umbraco.cms/businesslogic/macro/MacroEngineFactory.cs @@ -28,11 +28,13 @@ namespace umbraco.cms.businesslogic.macro internal static void EnsureInitialize() { - if (_isInitialized) - return; - - using (new WriteLock(Lock)) + using (var lck = new UpgradeableReadLock(Lock)) { + if (_isInitialized) + return; + + lck.UpgradeToWriteLock(); + AllEngines.Clear(); AllEngines.AddRange(