Buggy code:
public class LukeRequestHandler extends RequestHandlerBase { private static Logger log = LoggerFactory . getLogger ( LukeRequestHandler . class ) ; public static final String NUMTERMS = "numTerms" ; public static final String DOC_ID = "docId" ; public static final String ID = "id" ; public static final int DEFAULT_COUNT = 10 ; static final int HIST_ARRAY_SIZE = 33 ; private static enum ShowStyle { ALL , DOC , SCHEMA , INDEX ; public static LukeRequestHandler . ShowStyle get ( String v ) { } } @ Override public void handleRequestBody ( SolrQueryRequest req , SolrQueryResponse rsp ) throws Exception { } private static String getFieldFlags ( IndexableField f ) { } private static String getFieldFlags ( SchemaField f ) { } public static SimpleOrderedMap < String > getFieldFlagsKey ( ) { } private static SimpleOrderedMap < Object > getDocumentFieldsInfo ( Document doc , int docId , IndexReader reader , IndexSchema schema ) throws IOException { } @ SuppressWarnings ( "unchecked" ) private static SimpleOrderedMap < Object > getIndexedFieldsInfo ( SolrQueryRequest req ) throws Exception { } private static Document getFirstLiveDoc ( AtomicReader reader , String fieldName , Terms terms ) throws IOException { } private static SimpleOrderedMap < Object > getSchemaInfo ( IndexSchema schema ) { } private static SimpleOrderedMap < Object > getAnalyzerInfo ( Analyzer analyzer ) { } private static void populateFieldInfo ( IndexSchema schema , Map < String , List < String > > typeusemap , Map < String , Object > fields , SchemaField uniqueField , SchemaField f ) { } public static SimpleOrderedMap < Object > getIndexInfo ( DirectoryReader reader , boolean detail ) throws IOException { } public static SimpleOrderedMap < Object > getIndexInfo ( DirectoryReader reader ) throws IOException { } private static void getDetailedFieldInfo ( SolrQueryRequest req , String field , SimpleOrderedMap < Object > fieldMap ) throws IOException { SolrParams params = req . getParams ( ) ; int numTerms = params . getInt ( LukeRequestHandler . NUMTERMS , LukeRequestHandler . DEFAULT_COUNT ) ; LukeRequestHandler . TopTermQueue tiq = new LukeRequestHandler . TopTermQueue ( ( numTerms + 1 ) ) ; final CharsRef spare = new CharsRef ( ) ; Fields fields = MultiFields . getFields ( req . getSearcher ( ) . getIndexReader ( ) ) ; if ( fields == null ) { return ; } Terms terms = fields . terms ( field ) ; if ( terms == null ) { return ; } TermsEnum termsEnum = terms . iterator ( null ) ; BytesRef text ; int [ ] buckets = new int [ LukeRequestHandler . HIST_ARRAY_SIZE ] ; while ( ( text = termsEnum . next ( ) ) != null ) { int freq = termsEnum . docFreq ( ) ; int slot = 32 - ( Integer . numberOfLeadingZeros ( Math . max ( 0 , ( freq - 1 ) ) ) ) ; buckets [ slot ] = ( buckets [ slot ] ) + 1 ; if ( freq > ( tiq . minFreq ) ) { UnicodeUtil . UTF8toUTF16 ( text , spare ) ; String t = spare . toString ( ) ; <START_BUG> tiq . distinctTerms = new Long ( terms . getUniqueTermCount ( ) ) . intValue ( ) ; <END_BUG> tiq . add ( new LukeRequestHandler . TopTermQueue . TermInfo ( new Term ( field , t ) , termsEnum . docFreq ( ) ) ) ; if ( ( tiq . size ( ) ) > numTerms ) { tiq . pop ( ) ; tiq . minFreq = tiq . getTopTermInfo ( ) . docFreq ; } } } tiq . histogram . add ( buckets ) ; fieldMap . add ( "distinct" , tiq . distinctTerms ) ; fieldMap . add ( "topTerms" , tiq . toNamedList ( req . getSearcher ( ) . getSchema ( ) ) ) ; fieldMap . add ( "histogram" , tiq . histogram . toNamedList ( ) ) ; } @ Override public String getDescription ( ) { } @ Override public String getSource ( ) { } @ Override public URL [ ] getDocs ( ) { } static class TermHistogram { int _maxBucket = - 1 ; int [ ] _buckets = new int [ LukeRequestHandler . HIST_ARRAY_SIZE ] ; public void add ( int [ ] buckets ) { } public NamedList < Integer > toNamedList ( ) { } } private static class TopTermQueue extends PriorityQueue { static class TermInfo { TermInfo ( Term t , int df ) { } int docFreq ; Term term ; } public int minFreq = 0 ; public int distinctTerms = 0 ; public LukeRequestHandler . TermHistogram histogram ; TopTermQueue ( int size ) { } @ Override protected final boolean lessThan ( Object a , Object b ) { } public NamedList < Integer > toNamedList ( IndexSchema schema ) { } public LukeRequestHandler . TopTermQueue . TermInfo getTopTermInfo ( ) { } } }

Fix:
tiq . distinctTerms = new Long ( terms . size ( ) ) . intValue ( ) ;