Commit d35c301
Guard against negative-length dictionary lookup in HyphenationCompoundWordTokenFilter, #1072
HyphenationCompoundWordTokenFilter.Decompose() could pass a negative length
(partLength - 1 == -1) to CharArraySet.Contains when partLength == 0. This
happens when a term has leading non-letter characters (counted via
iIgnoreAtBeginning), which pushes real hyphenation points past the synthetic
end marker and yields two equal hyphenation points (e.g. "...rindfleisch" ->
[0,7,11,11]). With minSubwordSize == 0 the zero-length part is not filtered
out, and the genitive-'s fallback then probes the dictionary with length -1.
Upstream Java tolerates the negative length (its CharArrayMap silently treats
it as "not found"), but Lucene.NET's CharArrayMap validates its arguments and
throws ArgumentOutOfRangeException. Guard the fallback so a negative length is
never passed downstream, matching Java's effective behavior while leaving
CharArrayMap's validation intact for other callers.
This was the residual TestRandomChains failure under seed
0xc0ab8518c470366f:0x6ed44cef961049a2 reported on PR #1348.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>1 parent dac4a2b commit d35c301
2 files changed
Lines changed: 41 additions & 1 deletion
File tree
- src
- Lucene.Net.Analysis.Common/Analysis/Compound
- Lucene.Net.Tests.Analysis.Common/Analysis/Compound
Lines changed: 5 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
244 | 244 | | |
245 | 245 | | |
246 | 246 | | |
247 | | - | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
248 | 252 | | |
249 | 253 | | |
250 | 254 | | |
| |||
Lines changed: 36 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
266 | 267 | | |
267 | 268 | | |
268 | 269 | | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
269 | 305 | | |
270 | 306 | | |
271 | 307 | | |
| |||
0 commit comments