laimis opened a new pull request, #798:
URL: https://github.com/apache/lucenenet/pull/798

   Continuation of fixes with virtual calls being made from constructors. The 
issue originally reported by SonarCloud scans: 
https://sonarcloud.io/project/issues?resolved=false&rules=csharpsquid%3AS1699&id=apache_lucenenet
 and referenced in this issue: https://github.com/apache/lucenenet/issues/670
   
   I have changed my mind on TernaryTree and believe that making Init not 
virtual is a better fix than introducing locking/lazy initialization.
   
   TernaryTree is an internal class that's being subclassed by public 
HyphenationTree class. HyphenationTree does not call Init anywhere. This:
   
   ```c#
   internal class TernaryTree
   {
       public TernaryTree() { Init(); }
   
       protected virtual void Init() { ... }
   }
   
   public class HyphenationTree
   {
       public HyphenationTree () 
   }
   ```
   
   Since HyphenationTree is public, by removing the virtual from Init() we are 
breaking the API. Someone could have subclassed HyphenationTree and overridden 
Init() method. But it has to be a very low odds occurrence, and if someone has 
done that, they will get an error and have to deal with initialization as 
opposed code compiling successfully but then failing in surprising ways once 
run.
   
   Lucene.NET 3.0.3 has those classes commented out, no one would have done 
subclassing in that version. So people coming from 4.6.1 beta would be 
impacted, and we already have breaking changes that are part of beta.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@lucenenet.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to