You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by la...@apache.org on 2023/04/08 04:13:41 UTC
[lucenenet] branch master updated: BREAKING: remove virtual call from the constructor (#806)
This is an automated email from the ASF dual-hosted git repository.
laimis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/lucenenet.git
The following commit(s) were added to refs/heads/master by this push:
new 0e2ecb2b7 BREAKING: remove virtual call from the constructor (#806)
0e2ecb2b7 is described below
commit 0e2ecb2b7ef8d3817e3bf5bac20f58e81a9554a8
Author: Laimonas Simutis <la...@gmail.com>
AuthorDate: Fri Apr 7 21:13:36 2023 -0700
BREAKING: remove virtual call from the constructor (#806)
---
src/Lucene.Net/Util/SentinelIntSet.cs | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/src/Lucene.Net/Util/SentinelIntSet.cs b/src/Lucene.Net/Util/SentinelIntSet.cs
index 99f2990a0..b8de0977a 100644
--- a/src/Lucene.Net/Util/SentinelIntSet.cs
+++ b/src/Lucene.Net/Util/SentinelIntSet.cs
@@ -43,6 +43,11 @@ namespace Lucene.Net.Util
/// <para/>
/// NOTE: This was SentinelIntSet in Lucene
/// <para/>
+ ///
+ /// If you need to extend this class and subclass it, keep in mind that constructor
+ /// calls a private "ClearInternal" method and not virtual Clear. So if you need
+ /// to do some specific initialization in subclass constructor, call your own private
+ /// method with whatever custom initialization you need.
/// @lucene.internal
/// </summary>
public class SentinelInt32Set
@@ -84,12 +89,15 @@ namespace Lucene.Net.Util
keys = new int[tsize];
if (emptyVal != 0)
{
- Clear();
+ ClearInternal(); // LUCENENET specific - calling private and not virtual method
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public virtual void Clear()
+ public virtual void Clear() => ClearInternal();
+ // LUCENENET specific - S1699 - non-virtual method that can be
+ // called from the constructor
+ private void ClearInternal()
{
Arrays.Fill(keys, EmptyVal);
Count = 0;