summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2022-11-09 16:08:53 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2022-11-09 16:08:53 +0700
commitda13ced93565971e2551ab874b6a1804b9e2322a (patch)
treee2d397c7d58ca6a2eb1aefd9bc9f99374aba0030
parentAsn1Generator implements IDisposable (diff)
downloadBouncyCastle.NET-ed25519-da13ced93565971e2551ab874b6a1804b9e2322a.tar.xz
Various Close/Dispose cleanup
-rw-r--r--crypto/test/src/openpgp/test/PGPPBETest.cs8
-rw-r--r--crypto/test/src/openpgp/test/PGPRSATest.cs6
-rw-r--r--crypto/test/src/tls/test/NetworkStream.cs13
-rw-r--r--crypto/test/src/tls/test/PipedStream.cs24
4 files changed, 36 insertions, 15 deletions
diff --git a/crypto/test/src/openpgp/test/PGPPBETest.cs b/crypto/test/src/openpgp/test/PGPPBETest.cs
index 85d6b7bff..8bab78fd9 100644
--- a/crypto/test/src/openpgp/test/PGPPBETest.cs
+++ b/crypto/test/src/openpgp/test/PGPPBETest.cs
@@ -365,7 +365,13 @@ namespace Org.BouncyCastle.Bcpg.OpenPgp.Tests
 			{
 				throw new Exception("Close() called on underlying stream");
 			}
-		}
+
+            protected override void Dispose(bool disposing)
+            {
+				if (disposing)
+					throw new Exception("Dispose() called on underlying stream");
+            }
+        }
 
 		public override string Name
         {
diff --git a/crypto/test/src/openpgp/test/PGPRSATest.cs b/crypto/test/src/openpgp/test/PGPRSATest.cs
index d8b350b2d..6de95fbeb 100644
--- a/crypto/test/src/openpgp/test/PGPRSATest.cs
+++ b/crypto/test/src/openpgp/test/PGPRSATest.cs
@@ -1208,6 +1208,12 @@ namespace Org.BouncyCastle.Bcpg.OpenPgp.Tests
             {
                 throw new Exception("Close() called on underlying stream");
             }
+
+            protected override void Dispose(bool disposing)
+            {
+                if (disposing)
+                    throw new Exception("Dispose() called on underlying stream");
+            }
         }
 
         public override string Name
diff --git a/crypto/test/src/tls/test/NetworkStream.cs b/crypto/test/src/tls/test/NetworkStream.cs
index c5f1dfd59..ed1b21014 100644
--- a/crypto/test/src/tls/test/NetworkStream.cs
+++ b/crypto/test/src/tls/test/NetworkStream.cs
@@ -34,11 +34,6 @@ namespace Org.BouncyCastle.Tls.Tests
             get { return m_inner.CanWrite; }
         }
 
-        public override void Close()
-        {
-            lock (this) m_closed = true;
-        }
-
         public override void Flush()
         {
             m_inner.Flush();
@@ -89,6 +84,14 @@ namespace Org.BouncyCastle.Tls.Tests
             m_inner.WriteByte(value);
         }
 
+        protected override void Dispose(bool disposing)
+        {
+            if (disposing)
+            {
+                lock (this) m_closed = true;
+            }
+        }
+
         private void CheckNotClosed()
         {
             lock (this)
diff --git a/crypto/test/src/tls/test/PipedStream.cs b/crypto/test/src/tls/test/PipedStream.cs
index dfca35b81..95c3de465 100644
--- a/crypto/test/src/tls/test/PipedStream.cs
+++ b/crypto/test/src/tls/test/PipedStream.cs
@@ -41,15 +41,6 @@ namespace Org.BouncyCastle.Tls.Tests
             get { return true; }
         }
 
-        public override void Close()
-        {
-            lock (this)
-            {
-                m_closed = true;
-                Monitor.PulseAll(this);
-            }
-        }
-
         public override void Flush()
         {
         }
@@ -117,6 +108,21 @@ namespace Org.BouncyCastle.Tls.Tests
             }
         }
 
+        protected override void Dispose(bool disposing)
+        {
+            if (disposing)
+            {
+                lock (this)
+                {
+                    if (!m_closed)
+                    {
+                        m_closed = true;
+                        Monitor.PulseAll(this);
+                    }
+                }
+            }
+        }
+
         private void CheckOpen()
         {
             if (m_closed)