dweiss commented on a change in pull request #2207:
URL: https://github.com/apache/lucene-solr/pull/2207#discussion_r560184335



##########
File path: 
lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/SpellChecker.java
##########
@@ -24,22 +24,24 @@
  */
 public class SpellChecker {
   private final Dictionary dictionary;
-  private final ThreadLocal<Stemmer> stemmer;
-  private final ThreadLocal<BytesRef> scratch = 
ThreadLocal.withInitial(BytesRef::new);
+  private final BytesRef scratch = new BytesRef();
 
-  public SpellChecker(Dictionary dictionary) {
+  private SpellChecker(Dictionary dictionary) {

Review comment:
       I think the default reasoning is that nothing is thread safe unless 
stated otherwise, period. I don't see why the SpellChecker would be different 
here. It is a facade over a raw dictionary providing some functionality, seems 
quite natural to me for it just to expose a method to stem words (once built). 
A similar pattern is used in other places - like here:
   
   
https://github.com/apache/lucene-solr/blob/master/lucene/analysis/morfologik/src/java/org/apache/lucene/analysis/morfologik/MorfologikFilter.java#L79
   
   Neither MorfologikFilter nor the highlighted line (DictionaryLookup) are 
thread-safe. I imagine SpellChecker would correspond to what DictionaryLookup 
is in Morfologik's world.
   
   
https://github.com/morfologik/morfologik-stemming/blob/master/morfologik-stemming/src/main/java/morfologik/stemming/DictionaryLookup.java




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to