Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BREAKING: Make AbstractAnalysisFactory.Get non-virtual to avoid issues in constructors #800

Conversation

laimis
Copy link
Contributor

@laimis laimis commented Apr 6, 2023

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: #670

In this case, AbstractAnalysisFactory calls "Get" from the constructor. Get is virtual, but it does not feel like the intent here is to make that method extendable. It's a WIDELY extended class inside Lucene via TokenFilterFactory and all the classes that inherit from it, and none of them override Get implementations.

@laimis laimis changed the title BREAKING: Make Get non-virtual to avoid issues in constructors BREAKING: Make AbstractAnalysisFactory.Get non-virtual to avoid issues in constructors Apr 6, 2023
@laimis laimis requested a review from NightOwl888 April 6, 2023 17:48
Copy link
Contributor

@NightOwl888 NightOwl888 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

I think this was an intentional design decision, however, I suspect the abstract factories only exist to support SOLR and some Lucene tests. They don't really have much utility in .NET because of the odd constructors and weird way they need to be wired up with string dictionaries.

@laimis laimis merged commit 34e9f45 into apache:master Apr 6, 2023
@laimis laimis deleted the fix/virtual-calls-from-constructors-abstractanalysisfactory branch April 6, 2023 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants