(keyoword-extractor) Address very rare race condition in memoization logic

This commit is contained in:
Viktor Lofgren 2023-09-25 18:28:04 +02:00
parent f797a92f87
commit 9b781f8404

View File

@ -105,9 +105,10 @@ public class KeywordExtractor {
public WordSpan[] getKeywordsFromSentence(DocumentSentence sentence) {
if (sentence.keywords != null) {
return sentence.keywords.get();
}
var existingKeywords = sentence.keywords.get();
if (existingKeywords != null)
return existingKeywords;
List<WordSpan> spans = new ArrayList<>(2 * sentence.length());
for (int i = 0; i < sentence.length(); i++) {