[Mono-bugs] [Bug 644654] New: CryptoStream violates IDispose pattern

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Thu Oct 7 12:17:04 EDT 2010


https://bugzilla.novell.com/show_bug.cgi?id=644654

https://bugzilla.novell.com/show_bug.cgi?id=644654#c0


           Summary: CryptoStream violates IDispose pattern
    Classification: Mono
           Product: Mono: Class Libraries
           Version: 2.6.x
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: Mono.Security
        AssignedTo: spouliot at novell.com
        ReportedBy: bassam at symform.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---
           Blocker: ---


User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.10)
Gecko/20100914 Firefox/3.6.10 ( .NET CLR 3.5.30729; .NET4.0E)

CryptoStream seems to violate the IDispose pattern and System.IO.Stream, and
differs from the implementation on .NET.

The problem might be due to CryptoStream overriding Stream.Close instead of
doing it cleanup in Dispose(bool). This would also remove the need for
CryptoStream.Clear which I'm not sure where its called from.



Reproducible: Always

Steps to Reproduce:
Here is a test case that shows the problem.

        private class MyCryptoStream : CryptoStream
        {
            public MyCryptoStream(Stream stream, ICryptoTransform transform)
                : base(stream, transform, CryptoStreamMode.Read)
            {
            }

            protected override void Dispose(bool disposing)
            {
                base.Dispose(disposing);

                // This is called on .NET, but not on Mono.
                Console.WriteLine("MyCryptoStream.Dispose({0}) called",
disposing);
            }
        }

        [Test]
        public void CryptoStreamDescendant()
        {
            using (MemoryStream mem = new MemoryStream(new byte[] { 1, 2, 3 },
false))
            using (MyCryptoStream cs = new MyCryptoStream(mem, SHA1.Create()))
            {
            }
        }

-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.


More information about the mono-bugs mailing list