Buggy code:
public class TermsComponent extends SearchComponent { public static final int UNLIMITED_MAX_COUNT = - 1 ; public static final String COMPONENT_NAME = "terms" ; @ Override public void prepare ( ResponseBuilder rb ) throws IOException { } public void process ( ResponseBuilder rb ) throws IOException { SolrParams params = rb . req . getParams ( ) ; if ( ! ( params . getBool ( TERMS , false ) ) ) return ; String [ ] fields = params . getParams ( TERMS_FIELD ) ; NamedList termsResult = new SimpleOrderedMap ( ) ; rb . rsp . add ( "terms" , termsResult ) ; if ( ( fields == null ) || ( ( fields . length ) == 0 ) ) return ; int limit = params . getInt ( TERMS_LIMIT , 10 ) ; if ( limit < 0 ) { limit = Integer . MAX_VALUE ; } String lowerStr = params . get ( TERMS_LOWER ) ; String upperStr = params . get ( TERMS_UPPER ) ; boolean upperIncl = params . getBool ( TERMS_UPPER_INCLUSIVE , false ) ; boolean lowerIncl = params . getBool ( TERMS_LOWER_INCLUSIVE , true ) ; boolean sort = ! ( TERMS_SORT_INDEX . equals ( params . get ( TERMS_SORT , TERMS_SORT_COUNT ) ) ) ; int freqmin = params . getInt ( TERMS_MINCOUNT , 1 ) ; int freqmax = params . getInt ( TERMS_MAXCOUNT , TermsComponent . UNLIMITED_MAX_COUNT ) ; if ( freqmax < 0 ) { freqmax = Integer . MAX_VALUE ; } String prefix = params . get ( TERMS_PREFIX_STR ) ; String regexp = params . get ( TERMS_REGEXP_STR ) ; Pattern pattern = ( regexp != null ) ? Pattern . compile ( regexp , resolveRegexpFlags ( params ) ) : null ; boolean raw = params . getBool ( TERMS_RAW , false ) ; SolrIndexReader sr = rb . req . getSearcher ( ) . getReader ( ) ; Fields lfields = MultiFields . getFields ( sr ) ; for ( String field : fields ) { NamedList fieldTerms = new NamedList ( ) ; termsResult . add ( field , fieldTerms ) ; <START_BUG> Terms terms = lfields . terms ( field ) ; <END_BUG> if ( terms == null ) { continue ; } FieldType ft = ( raw ) ? null : rb . req . getSchema ( ) . getFieldTypeNoEx ( field ) ; if ( ft == null ) ft = new StrField ( ) ; BytesRef prefixBytes = ( prefix == null ) ? null : new BytesRef ( prefix ) ; BytesRef upperBytes = null ; if ( upperStr != null ) { upperBytes = new BytesRef ( ) ; ft . readableToIndexed ( upperStr , upperBytes ) ; } BytesRef lowerBytes ; if ( lowerStr == null ) { lowerBytes = prefixBytes ; } else { lowerBytes = new BytesRef ( ) ; if ( raw ) { lowerBytes = new BytesRef ( lowerStr ) ; } else { lowerBytes = new BytesRef ( ) ; ft . readableToIndexed ( lowerStr , lowerBytes ) ; } } TermsEnum termsEnum = terms . iterator ( ) ; BytesRef term = null ; if ( lowerBytes != null ) { if ( ( termsEnum . seek ( lowerBytes , true ) ) == ( SeekStatus . END ) ) { termsEnum = null ; } else { term = termsEnum . term ( ) ; if ( ( lowerIncl == false ) && ( term . equals ( lowerBytes ) ) ) { term = termsEnum . next ( ) ; } } } else { term = termsEnum . next ( ) ; } int i = 0 ; BoundedTreeSet < CountPair < BytesRef , Integer > > queue = ( sort ) ? new BoundedTreeSet < CountPair < BytesRef , Integer > > ( limit ) : null ; CharArr external = new CharArr ( ) ; while ( ( term != null ) && ( ( i < limit ) || sort ) ) { boolean externalized = false ; if ( ( prefixBytes != null ) && ( ! ( term . startsWith ( prefixBytes ) ) ) ) break ; if ( pattern != null ) { external . reset ( ) ; ft . indexedToReadable ( term , external ) ; if ( ! ( pattern . matcher ( external ) . matches ( ) ) ) { term = termsEnum . next ( ) ; continue ; } } if ( upperBytes != null ) { int upperCmp = term . compareTo ( upperBytes ) ; if ( ( upperCmp > 0 ) || ( ( upperCmp == 0 ) && ( ! upperIncl ) ) ) break ; } int docFreq = termsEnum . docFreq ( ) ; if ( ( docFreq >= freqmin ) && ( docFreq <= freqmax ) ) { if ( sort ) { queue . add ( new CountPair < BytesRef , Integer > ( new BytesRef ( term ) , docFreq ) ) ; } else { if ( ! externalized ) { external . reset ( ) ; ft . indexedToReadable ( term , external ) ; } String label = external . toString ( ) ; fieldTerms . add ( label , docFreq ) ; i ++ ; } } term = termsEnum . next ( ) ; } if ( sort ) { for ( CountPair < BytesRef , Integer > item : queue ) { if ( i >= limit ) break ; external . reset ( ) ; ft . indexedToReadable ( item . key , external ) ; fieldTerms . add ( external . toString ( ) , item . val ) ; i ++ ; } } } } int resolveRegexpFlags ( SolrParams params ) { } @ Override public int distributedProcess ( ResponseBuilder rb ) throws IOException { }

Fix:
Terms terms = ( lfields == null ) ? null : lfields . terms ( field ) ;