So your fix avoids any exception altogether. On 3x, you just stop
loading when we hit a termOrd > number of docs. On trunk, we keep
loading, simply growing the array as needed.
I'm torn on what the best disposition here is. This API should only
be used on single-token (per doc) fields, so this handling we're
adding/fixing is about how to handle the misuse of the API.
Neither solution is great – throwing an exception is nasty since you
could be fine for some time and then only on indexing enough docs,
perhaps well into production, trip the exception. But then silently
pretending nothing is wrong is also not great because the app then has
Really this'd be a great time to use a logging framework – we'd drop
a error, and then not throw an exception.
Net/net I think your solution (don't throw an exception) is the lesser
evil at this time, so I think we should go with that.
But: I think we should also fix trunk? Ie, if hit termOrd > numDocs,
silently break, instead of trying to grow the array. Because now (on
trunk) if you try to load a DocTermsIndex on a large tokenized text
field in a large index you'll (try to) use insane amounts of memory...