From 7f147fece08363dc13f0dbdf51a849de7e93cce3 Mon Sep 17 00:00:00 2001 From: Peter Gromov Date: Wed, 7 Apr 2021 14:52:36 +0200 Subject: [PATCH] LUCENE-9894: Hunspell: add user-friendly diagnostics for morph data API misuse (#51) --- .../java/org/apache/lucene/analysis/hunspell/Dictionary.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/Dictionary.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/Dictionary.java index 2be818812b1..2e83145ba2f 100644 --- a/lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/Dictionary.java +++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/Dictionary.java @@ -551,8 +551,9 @@ public class Dictionary { @Override public List getMorphologicalValues(int entryIndex, String key) { - assert key.length() == 3; - assert key.charAt(2) == ':'; + assert key.length() == 3 && key.charAt(2) == ':' + : "A morphological data key should consist of two letters followed by a semicolon, found: " + + key; String fields = getMorphologicalData(entryIndex); if (fields.isEmpty() || !fields.contains(key)) return Collections.emptyList();