Apache Solr open-source search software
LUCENE-9770: Hunspell: don't perform compound check recursively when looking for space-separated word pairs (#2368)
Peter Gromovb20e2775693c
diff --git a/lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/Hunspell.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/Hunspell.javaindex 04bd55840ce..3286f86c1b0 100644--- a/lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/Hunspell.java+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/Hunspell.java@@ -311,11 +311,12 @@ public class Hunspell {return false;}- String spaceSeparated =- new String(tail.chars, tail.offset, length)- + " "- + new String(tail.chars, tail.offset + length, nextPartLength);- return !checkWord(spaceSeparated);+ char[] spaceSeparated = new char[length + nextPartLength + 1];+ System.arraycopy(tail.chars, tail.offset, spaceSeparated, 0, length);+ System.arraycopy(+ tail.chars, tail.offset + length, spaceSeparated, length + 1, nextPartLength);+ spaceSeparated[length] = ' ';+ return !Boolean.TRUE.equals(checkSimpleWord(spaceSeparated, spaceSeparated.length, null));}private boolean isMisspelledSimpleWord(int length, WordCase originalCase) {