lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nightowl...@apache.org
Subject [13/20] lucenenet git commit: Lucene.Net.Core.InfoStream: implemented .NET dispose pattern
Date Sun, 02 Apr 2017 07:06:13 GMT
Lucene.Net.Core.InfoStream: implemented .NET dispose pattern


Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/35430a9b
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/35430a9b
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/35430a9b

Branch: refs/heads/api-work
Commit: 35430a9b7408e56a5754cebbffe837d8ee6643f6
Parents: 99e1576
Author: Shad Storhaug <shad@shadstorhaug.com>
Authored: Sun Apr 2 11:26:19 2017 +0700
Committer: Shad Storhaug <shad@shadstorhaug.com>
Committed: Sun Apr 2 11:58:35 2017 +0700

----------------------------------------------------------------------
 src/Lucene.Net.Core/Util/InfoStream.cs                   | 11 +++++++++--
 src/Lucene.Net.Core/Util/PrintStreamInfoStream.cs        |  4 ++--
 src/Lucene.Net.TestFramework/Index/RandomIndexWriter.cs  |  7 +++++--
 .../Util/FailOnNonBulkMergesInfoStream.cs                |  2 +-
 src/Lucene.Net.TestFramework/Util/NullInfoStream.cs      |  2 +-
 src/Lucene.Net.Tests/Index/TestIndexWriterExceptions.cs  |  4 ++--
 src/Lucene.Net.Tests/Index/TestIndexWriterReader.cs      |  2 +-
 7 files changed, 21 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/35430a9b/src/Lucene.Net.Core/Util/InfoStream.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/InfoStream.cs b/src/Lucene.Net.Core/Util/InfoStream.cs
index d9a6362..8d97037 100644
--- a/src/Lucene.Net.Core/Util/InfoStream.cs
+++ b/src/Lucene.Net.Core/Util/InfoStream.cs
@@ -47,7 +47,7 @@ namespace Lucene.Net.Util
                 return false;
             }
 
-            public override void Dispose()
+            protected override void Dispose(bool disposing)
             {
             }
         }
@@ -87,7 +87,14 @@ namespace Lucene.Net.Util
             }
         }
 
-        public virtual void Dispose()
+        // LUCENENET specific - implementing proper dispose pattern
+        public void Dispose()
+        {
+            Dispose(true);
+            GC.SuppressFinalize(this);
+        }
+
+        protected virtual void Dispose(bool disposing)
         {
         }
 

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/35430a9b/src/Lucene.Net.Core/Util/PrintStreamInfoStream.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/PrintStreamInfoStream.cs b/src/Lucene.Net.Core/Util/PrintStreamInfoStream.cs
index ba473db..63d0f95 100644
--- a/src/Lucene.Net.Core/Util/PrintStreamInfoStream.cs
+++ b/src/Lucene.Net.Core/Util/PrintStreamInfoStream.cs
@@ -58,9 +58,9 @@ namespace Lucene.Net.Util
             return true;
         }
 
-        public override void Dispose()
+        protected override void Dispose(bool disposing)
         {
-            if (!IsSystemStream)
+            if (disposing && !IsSystemStream)
             {
                 m_stream.Dispose();
             }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/35430a9b/src/Lucene.Net.TestFramework/Index/RandomIndexWriter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Index/RandomIndexWriter.cs b/src/Lucene.Net.TestFramework/Index/RandomIndexWriter.cs
index 03504c2..2eb3aa7 100644
--- a/src/Lucene.Net.TestFramework/Index/RandomIndexWriter.cs
+++ b/src/Lucene.Net.TestFramework/Index/RandomIndexWriter.cs
@@ -543,9 +543,12 @@ namespace Lucene.Net.Index
                 this.TestPoint = testPoint;
             }
 
-            public override void Dispose()
+            protected override void Dispose(bool disposing)
             {
-                @delegate.Dispose();
+                if (disposing)
+                {
+                    @delegate.Dispose();
+                }
             }
 
             public override void Message(string component, string message)

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/35430a9b/src/Lucene.Net.TestFramework/Util/FailOnNonBulkMergesInfoStream.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Util/FailOnNonBulkMergesInfoStream.cs b/src/Lucene.Net.TestFramework/Util/FailOnNonBulkMergesInfoStream.cs
index e6b3a4a..4deb2eb 100644
--- a/src/Lucene.Net.TestFramework/Util/FailOnNonBulkMergesInfoStream.cs
+++ b/src/Lucene.Net.TestFramework/Util/FailOnNonBulkMergesInfoStream.cs
@@ -24,7 +24,7 @@ namespace Lucene.Net.Util
     // TODO: we should probably be a wrapper so verbose still works...
     public class FailOnNonBulkMergesInfoStream : InfoStream
     {
-        public override void Dispose()
+        protected override void Dispose(bool disposing)
         {
         }
 

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/35430a9b/src/Lucene.Net.TestFramework/Util/NullInfoStream.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Util/NullInfoStream.cs b/src/Lucene.Net.TestFramework/Util/NullInfoStream.cs
index baa8c21..42c0590 100644
--- a/src/Lucene.Net.TestFramework/Util/NullInfoStream.cs
+++ b/src/Lucene.Net.TestFramework/Util/NullInfoStream.cs
@@ -38,7 +38,7 @@ namespace Lucene.Net.Util
             return true; // to actually enable logging, we just ignore on message()
         }
 
-        public override void Dispose()
+        protected override void Dispose(bool disposing)
         {
         }
     }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/35430a9b/src/Lucene.Net.Tests/Index/TestIndexWriterExceptions.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/Index/TestIndexWriterExceptions.cs b/src/Lucene.Net.Tests/Index/TestIndexWriterExceptions.cs
index ed5587f..bad1448 100644
--- a/src/Lucene.Net.Tests/Index/TestIndexWriterExceptions.cs
+++ b/src/Lucene.Net.Tests/Index/TestIndexWriterExceptions.cs
@@ -1319,7 +1319,7 @@ namespace Lucene.Net.Index
                 return true;
             }
 
-            public override void Dispose()
+            protected override void Dispose(bool disposing)
             {
             }
         }
@@ -2515,7 +2515,7 @@ namespace Lucene.Net.Index
                 return true;
             }
 
-            public override void Dispose()
+            protected override void Dispose(bool disposing)
             {
             }
         }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/35430a9b/src/Lucene.Net.Tests/Index/TestIndexWriterReader.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/Index/TestIndexWriterReader.cs b/src/Lucene.Net.Tests/Index/TestIndexWriterReader.cs
index fd8032e..42697a2 100644
--- a/src/Lucene.Net.Tests/Index/TestIndexWriterReader.cs
+++ b/src/Lucene.Net.Tests/Index/TestIndexWriterReader.cs
@@ -1237,7 +1237,7 @@ namespace Lucene.Net.Index
                 this.DidWarm = didWarm;
             }
 
-            public override void Dispose()
+            protected override void Dispose(bool disposing)
             {
             }
 


Mime
View raw message