Buggy code:
public abstract class AnalysisRequestHandlerBase extends RequestHandlerBase { public static final Set < BytesRef > EMPTY_BYTES_SET = Collections . emptySet ( ) ; @ Override public void handleRequestBody ( SolrQueryRequest req , SolrQueryResponse rsp ) throws Exception { } protected abstract NamedList doAnalysis ( SolrQueryRequest req ) throws Exception { } protected NamedList < ? extends Object > analyzeValue ( String value , AnalysisRequestHandlerBase . AnalysisContext context ) { Analyzer analyzer = context . getAnalyzer ( ) ; if ( ! ( TokenizerChain . class . isInstance ( analyzer ) ) ) { TokenStream tokenStream = null ; try { tokenStream = analyzer . tokenStream ( context . getFieldName ( ) , new StringReader ( value ) ) ; } catch ( IOException e ) { throw new org . apache . solr . common . SolrException ( ErrorCode . BAD_REQUEST , e ) ; } NamedList < List < NamedList > > namedList = new NamedList < List < NamedList > > ( ) ; namedList . add ( tokenStream . getClass ( ) . getName ( ) , convertTokensToNamedLists ( analyzeTokenStream ( tokenStream ) , context ) ) ; return namedList ; } TokenizerChain tokenizerChain = ( ( TokenizerChain ) ( analyzer ) ) ; CharFilterFactory [ ] cfiltfacs = tokenizerChain . getCharFilterFactories ( ) ; TokenizerFactory tfac = tokenizerChain . getTokenizerFactory ( ) ; TokenFilterFactory [ ] filtfacs = tokenizerChain . getTokenFilterFactories ( ) ; NamedList < Object > namedList = new NamedList < Object > ( ) ; if ( cfiltfacs != null ) { String source = value ; for ( CharFilterFactory cfiltfac : cfiltfacs ) { CharStream reader = CharReader . get ( new StringReader ( source ) ) ; reader = cfiltfac . create ( reader ) ; source = writeCharStream ( namedList , reader ) ; } } <START_BUG> TokenStream tokenStream = tfac . create ( tokenizerChain . initReader ( new StringReader ( value ) ) ) ; <END_BUG> List < AttributeSource > tokens = analyzeTokenStream ( tokenStream ) ; namedList . add ( tokenStream . getClass ( ) . getName ( ) , convertTokensToNamedLists ( tokens , context ) ) ; AnalysisRequestHandlerBase . ListBasedTokenStream listBasedTokenStream = new AnalysisRequestHandlerBase . ListBasedTokenStream ( tokens ) ; for ( TokenFilterFactory tokenFilterFactory : filtfacs ) { for ( final AttributeSource tok : tokens ) { tok . getAttribute ( AnalysisRequestHandlerBase . TokenTrackingAttribute . class ) . freezeStage ( ) ; } tokenStream = tokenFilterFactory . create ( listBasedTokenStream ) ; tokens = analyzeTokenStream ( tokenStream ) ; namedList . add ( tokenStream . getClass ( ) . getName ( ) , convertTokensToNamedLists ( tokens , context ) ) ; listBasedTokenStream = new AnalysisRequestHandlerBase . ListBasedTokenStream ( tokens ) ; } return namedList ; } protected Set < BytesRef > getQueryTokenSet ( String query , Analyzer analyzer ) { } private List < AttributeSource > analyzeTokenStream ( TokenStream tokenStream ) { } static Map < String , String > ATTRIBUTE_MAPPING = Collections . unmodifiableMap ( new HashMap < String , String > ( ) { } ) ; private List < NamedList > convertTokensToNamedLists ( final List < AttributeSource > tokenList , AnalysisRequestHandlerBase . AnalysisContext context ) { } private String writeCharStream ( NamedList < Object > out , CharStream input ) { } protected static final class ListBasedTokenStream extends TokenStream { private final List < AttributeSource > tokens ; private Iterator < AttributeSource > tokenIterator ; ListBasedTokenStream ( List < AttributeSource > tokens ) { } @ Override public boolean incrementToken ( ) throws IOException { } @ Override public void reset ( ) throws IOException { } } public interface TokenTrackingAttribute extends Attribute { void freezeStage ( ) { } void setActPosition ( int pos ) { } int [ ] getPositions ( ) { } void reset ( int [ ] basePositions , int position ) { } } public static final class TokenTrackingAttributeImpl extends AttributeImpl implements AnalysisRequestHandlerBase . TokenTrackingAttribute { private int [ ] basePositions = new int [ 0 ] ; private int position = 0 ; private transient int [ ] cachedPositions = null ; public void freezeStage ( ) { } public void setActPosition ( int pos ) { } public int [ ] getPositions ( ) { } public void reset ( int [ ] basePositions , int position ) { } @ Override public void clear ( ) { } @ Override public void reflectWith ( AttributeReflector reflector ) { } @ Override public void copyTo ( AttributeImpl target ) { } } protected static class AnalysisContext { private final String fieldName ; private final FieldType fieldType ; private final Analyzer analyzer ; private final Set < BytesRef > termsToMatch ; public AnalysisContext ( FieldType fieldType , Analyzer analyzer , Set < BytesRef > termsToMatch ) { } public AnalysisContext ( String fieldName , FieldType fieldType , Analyzer analyzer ) { } public AnalysisContext ( String fieldName , FieldType fieldType , Analyzer analyzer , Set < BytesRef > termsToMatch ) { } public String getFieldName ( ) { } public FieldType getFieldType ( ) { } public Analyzer getAnalyzer ( ) { } public Set < BytesRef > getTermsToMatch ( ) { } } }

Fix:
TokenStream tokenStream = tfac . create ( tokenizerChain . initReader ( null , new StringReader ( value ) ) ) ;