lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nightowl...@apache.org
Subject [17/20] lucenenet git commit: Lucene.Net.Codecs.TermsIndexReaderBase: implemented .NET dispose pattern
Date Sun, 02 Apr 2017 07:06:17 GMT
Lucene.Net.Codecs.TermsIndexReaderBase: 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/c2ec3e25
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/c2ec3e25
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/c2ec3e25

Branch: refs/heads/api-work
Commit: c2ec3e258e2a56ba34d1e1ee6d01660f7f478802
Parents: 8145821
Author: Shad Storhaug <shad@shadstorhaug.com>
Authored: Sun Apr 2 11:35:05 2017 +0700
Committer: Shad Storhaug <shad@shadstorhaug.com>
Committed: Sun Apr 2 11:58:36 2017 +0700

----------------------------------------------------------------------
 .../BlockTerms/FixedGapTermsIndexReader.cs                  | 9 ++++++---
 src/Lucene.Net.Codecs/BlockTerms/TermsIndexReaderBase.cs    | 9 ++++++++-
 .../BlockTerms/VariableGapTermsIndexReader.cs               | 9 ++++++---
 3 files changed, 20 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c2ec3e25/src/Lucene.Net.Codecs/BlockTerms/FixedGapTermsIndexReader.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/BlockTerms/FixedGapTermsIndexReader.cs b/src/Lucene.Net.Codecs/BlockTerms/FixedGapTermsIndexReader.cs
index 10d774a..92f6a95 100644
--- a/src/Lucene.Net.Codecs/BlockTerms/FixedGapTermsIndexReader.cs
+++ b/src/Lucene.Net.Codecs/BlockTerms/FixedGapTermsIndexReader.cs
@@ -460,11 +460,14 @@ namespace Lucene.Net.Codecs.BlockTerms
             }
         }
 
-        public override void Dispose()
+        protected override void Dispose(bool disposing)
         {
-            if (input != null && !indexLoaded)
+            if (disposing)
             {
-                input.Dispose();
+                if (input != null && !indexLoaded)
+                {
+                    input.Dispose();
+                }
             }
         }
 

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c2ec3e25/src/Lucene.Net.Codecs/BlockTerms/TermsIndexReaderBase.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/BlockTerms/TermsIndexReaderBase.cs b/src/Lucene.Net.Codecs/BlockTerms/TermsIndexReaderBase.cs
index 6323e7e..d7b905f 100644
--- a/src/Lucene.Net.Codecs/BlockTerms/TermsIndexReaderBase.cs
+++ b/src/Lucene.Net.Codecs/BlockTerms/TermsIndexReaderBase.cs
@@ -40,7 +40,14 @@ namespace Lucene.Net.Codecs.BlockTerms
     {
         public abstract FieldIndexEnum GetFieldEnum(FieldInfo fieldInfo);
 
-        public abstract void Dispose();
+        // LUCENENET specific - implementing proper dispose pattern
+        public void Dispose()
+        {
+            Dispose(true);
+            GC.SuppressFinalize(this);
+        }
+
+        protected abstract void Dispose(bool disposing);
 
         public abstract bool SupportsOrd { get; }
 

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c2ec3e25/src/Lucene.Net.Codecs/BlockTerms/VariableGapTermsIndexReader.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/BlockTerms/VariableGapTermsIndexReader.cs b/src/Lucene.Net.Codecs/BlockTerms/VariableGapTermsIndexReader.cs
index fe56cc9..ca773c0 100644
--- a/src/Lucene.Net.Codecs/BlockTerms/VariableGapTermsIndexReader.cs
+++ b/src/Lucene.Net.Codecs/BlockTerms/VariableGapTermsIndexReader.cs
@@ -278,11 +278,14 @@ namespace Lucene.Net.Codecs.BlockTerms
             }
         }
 
-        public override void Dispose()
+        protected override void Dispose(bool disposing)
         {
-            if (input != null && !indexLoaded)
+            if (disposing)
             {
-                input.Dispose();
+                if (input != null && !indexLoaded)
+                {
+                    input.Dispose();
+                }
             }
         }
 


Mime
View raw message