fixes a locking issue and exception logging

This commit is contained in:
Shannon
2014-03-10 12:55:45 +11:00
parent 6a9a1d1547
commit c26b72bd10
2 changed files with 17 additions and 6 deletions

View File

@@ -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<AngularJsonMediaTypeFormatter>("An error occurred writing to the output stream", ex);
throw;
}
memStream.Flush();
memStream.Position = 0;

View File

@@ -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(