From 047f797a996c899e1f52e58f47319e77250edae6 Mon Sep 17 00:00:00 2001 From: Grisha Kotler Date: Sun, 15 Oct 2023 22:18:38 +0300 Subject: [PATCH 1/2] RavenDB-21305 - add a finalizer to TermInfosReader --- src/Lucene.Net/Index/TermInfosReader.cs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/Lucene.Net/Index/TermInfosReader.cs b/src/Lucene.Net/Index/TermInfosReader.cs index 5afbe96491..39069a4e8e 100644 --- a/src/Lucene.Net/Index/TermInfosReader.cs +++ b/src/Lucene.Net/Index/TermInfosReader.cs @@ -143,7 +143,10 @@ public int MaxSkipLevels public void Dispose() { - if (isDisposed) return; + if (isDisposed) + return; + + GC.SuppressFinalize(this); // Move to protected method if class becomes unsealed if (origEnum != null) @@ -156,6 +159,18 @@ public void Dispose() isDisposed = true; } + + ~TermInfosReader() + { + // each TermInfosReader holds a cache (ArrayHolder) which is created upon creation of the TermInfosReader instance. + // in the past we created a new ArrayHolder when creating a new TermInfosReader instance. + // if it wasn't disposed, nothing happened since we have a finalizer for the ArrayHolder. + // we changed the implementation and now this cache is shared between different instances of TermInfosReader. + // when TermInfosReader isn't disposed we are still holding a reference to the ArrayHolder. + + // releasing the reference for the cached ArrayHolder will match the previous behaviour. + _termsIndexCache?.ReleaseRef(); + } /// Returns the number of term/value pairs in the set. internal long Size() From 34bc333c964b47e4c8069e726ba1d316d07eb664 Mon Sep 17 00:00:00 2001 From: Grisha Kotler Date: Sun, 15 Oct 2023 22:27:01 +0300 Subject: [PATCH 2/2] RavenDB-21305 - bump Lucene version --- src/Directory.Build.props | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Directory.Build.props b/src/Directory.Build.props index cb9ac55634..2b389e54a7 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -1,7 +1,7 @@ - 3.0.54010 - 3.0.54010.0 + 3.0.54011 + 3.0.54011.0 latest embedded