[ 
https://issues.apache.org/jira/browse/OPENNLP-1320?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17636045#comment-17636045
 ] 

ASF GitHub Bot commented on OPENNLP-1320:
-----------------------------------------

kinow commented on code in PR #385:
URL: https://github.com/apache/opennlp/pull/385#discussion_r1026909511


##########
opennlp-morfologik-addon/src/main/java/opennlp/morfologik/lemmatizer/MorfologikLemmatizer.java:
##########
@@ -47,7 +47,7 @@ public MorfologikLemmatizer(Dictionary dictionary) throws 
IllegalArgumentExcepti
     dictLookup = new DictionaryLookup(dictionary);
   }
 
-  private List<String> lemmatize(String word, String postag) {
+  private synchronized List<String> lemmatize(String word, String postag) {

Review Comment:
   >That would avoid the synchronization cost. Wdyt?
   
   That sounds like a good option to me. Avoids the `synchronized`, shouldn't 
add too much overhead, and the lib developers suggest it too. +1, thanks @rzo1 !





> Makes lemmatize of MorfologikLemmatizer thread-safe
> ---------------------------------------------------
>
>                 Key: OPENNLP-1320
>                 URL: https://issues.apache.org/jira/browse/OPENNLP-1320
>             Project: OpenNLP
>          Issue Type: Bug
>            Reporter: Lucas Avanço
>            Priority: Major
>
> The method lemmatize of MorfologikLemmatizer is not thread-safe.
> Concurrent invokes may rise exceptions and return unpredictable resutls.
> It seems that the whole method must be sync because the variable returned by 
> the morfologik lib is shared between threads.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to