Skip to content

Commit

Permalink
BREAKING: Fix/virtual calls from constructors for cell (#808)
Browse files Browse the repository at this point in the history
  • Loading branch information
laimis authored Apr 8, 2023
1 parent ba80653 commit fdc6325
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/Lucene.Net.Spatial/Prefix/Tree/Cell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ protected Cell(SpatialPrefixTree spatialPrefixTree, string token)
if (token.Length > 0 && token[token.Length - 1] == (char)LEAF_BYTE)
{
this.token = token.Substring(0, (token.Length - 1) - 0);
SetLeaf();
// LUCENENET specific - calling private instead of virtual to avoid initialization issues
SetLeafInternal();
}
if (Level == 0)
{
Expand Down Expand Up @@ -157,7 +158,9 @@ private void B_fixLeaf()
if (bytes![b_off + b_len - 1] == LEAF_BYTE)
{
b_len--;
SetLeaf();
// LUCENENET specific - calling internal vs virtual
// to avoid issues when this is called from constructor
SetLeafInternal();
}
else
{
Expand All @@ -175,7 +178,11 @@ private void B_fixLeaf()
public virtual bool IsLeaf => m_leaf;

/// <summary>Note: not supported at level 0.</summary>
public virtual void SetLeaf()
public virtual void SetLeaf() => SetLeafInternal();

// LUCENENET specific - S1699 - private method that can be called
// from constructor without causing initialization issues
private void SetLeafInternal()
{
if (Debugging.AssertsEnabled) Debugging.Assert(Level != 0);
m_leaf = true;
Expand Down

0 comments on commit fdc6325

Please sign in to comment.