Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit f2dd91b

Browse files
committed
Add MuteDuplicateDisposeExceptions option to suppress duplicate dispose MS errors
1 parent 6c2d212 commit f2dd91b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/ServiceStack.Text/RecyclableMemoryStream.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ namespace ServiceStack.Text //Internalize to avoid conflicts
3636

3737
public static class MemoryStreamFactory
3838
{
39-
public static bool UseRecyclableMemoryStream = true;
39+
public static bool UseRecyclableMemoryStream { get; set; }
40+
public static bool MuteDuplicateDisposeExceptions { get; set; }
4041

4142
#if !SL5
4243
public static RecyclableMemoryStreamManager RecyclableInstance = new RecyclableMemoryStreamManager();
@@ -912,6 +913,9 @@ protected override void Dispose(bool disposing)
912913
}
913914

914915
Events.Write.MemoryStreamDoubleDispose(this.id, this.tag, this.allocationStack, this.disposeStack, doubleDisposeStack);
916+
if (MemoryStreamFactory.MuteDuplicateDisposeExceptions)
917+
return;
918+
915919
throw new InvalidOperationException("Cannot dispose of RecyclableMemoryStream twice");
916920
}
917921

0 commit comments

Comments
 (0)