fixes a locking issue and exception logging
This commit is contained in:
@@ -7,6 +7,7 @@ using System.Net.Http;
|
|||||||
using System.Net.Http.Formatting;
|
using System.Net.Http.Formatting;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Umbraco.Core.Logging;
|
||||||
|
|
||||||
namespace Umbraco.Web.WebApi
|
namespace Umbraco.Web.WebApi
|
||||||
{
|
{
|
||||||
@@ -32,8 +33,16 @@ namespace Umbraco.Web.WebApi
|
|||||||
|
|
||||||
using (var memStream = new MemoryStream())
|
using (var memStream = new MemoryStream())
|
||||||
{
|
{
|
||||||
//Let the base class do all the processing using our custom stream
|
try
|
||||||
await base.WriteToStreamAsync(type, value, memStream, content, transportContext);
|
{
|
||||||
|
//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.Flush();
|
||||||
memStream.Position = 0;
|
memStream.Position = 0;
|
||||||
|
|||||||
@@ -28,11 +28,13 @@ namespace umbraco.cms.businesslogic.macro
|
|||||||
|
|
||||||
internal static void EnsureInitialize()
|
internal static void EnsureInitialize()
|
||||||
{
|
{
|
||||||
if (_isInitialized)
|
using (var lck = new UpgradeableReadLock(Lock))
|
||||||
return;
|
|
||||||
|
|
||||||
using (new WriteLock(Lock))
|
|
||||||
{
|
{
|
||||||
|
if (_isInitialized)
|
||||||
|
return;
|
||||||
|
|
||||||
|
lck.UpgradeToWriteLock();
|
||||||
|
|
||||||
AllEngines.Clear();
|
AllEngines.Clear();
|
||||||
|
|
||||||
AllEngines.AddRange(
|
AllEngines.AddRange(
|
||||||
|
|||||||
Reference in New Issue
Block a user