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/07 19:09:38 UTC

[lucenenet] branch master updated: BREAKING: remove virtual method call from constructor in OpenStringBuilder (#803)

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 bba68d25e BREAKING: remove virtual method call from constructor in OpenStringBuilder (#803)
bba68d25e is described below

commit bba68d25e650ab776cb48156c6f0ad9f83cf2a00
Author: Laimonas Simutis <la...@gmail.com>
AuthorDate: Fri Apr 7 12:09:32 2023 -0700

    BREAKING: remove virtual method call from constructor in OpenStringBuilder (#803)
    
    * remove virtual method call from constructor
---
 .../Analysis/Util/OpenStringBuilder.cs                         | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Util/OpenStringBuilder.cs b/src/Lucene.Net.Analysis.Common/Analysis/Util/OpenStringBuilder.cs
index 873421ccc..7955cbd9e 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Util/OpenStringBuilder.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Util/OpenStringBuilder.cs
@@ -47,7 +47,8 @@ namespace Lucene.Net.Analysis.Util
 
         public OpenStringBuilder(char[] arr, int len)
         {
-            Set(arr, len);
+            // LUCENENET specific - calling private method instead of public virtual
+            SetInternal(arr, len);
         }
 
         public virtual int Length
@@ -56,7 +57,12 @@ namespace Lucene.Net.Analysis.Util
             set => m_len = value;
         }
 
-        public virtual void Set(char[] arr, int end)
+        public virtual void Set(char[] arr, int end) => SetInternal(arr, end);
+
+        // LUCENENET specific - S1699 - introduced this to allow the constructor to
+        // still call "Set" functionality without having to call the virtual method
+        // that could be overridden by a subclass and don't have the state it expects
+        private void SetInternal(char[] arr, int end)
         {
             this.m_buf = arr;
             this.m_len = end;