Fix Lucene's getFiniteStrings to not consume Java stack

This pull request just copies in the fix for https://issues.apache.org/jira/browse/LUCENE-5628 to avoid problems like http://build.elasticsearch.com/job/es_jdk8_medium_master/34/jdk=JDK8,label=ubuntu-12-64-0-metal/testReport/junit/org.elasticsearch.search.suggest.completion/CompletionPostingsFormatTest/testDuellCompletions/ where a too-big string passed to the suggester can result in exhausting the Java stack.

Once LUCENE-5628 is fixed (I expect in 4.9), and we upgrade to it, we can remove this XSpecialOperations.