Buggy code:
public List < Grouping . Command > getCommands ( ) { } public void execute ( ) throws IOException { } private void searchWithTimeLimiter ( final Filter luceneFilter , Collector collector ) throws IOException { } int getMax ( int offset , int len , int max ) { } public boolean isSignalCacheWarning ( ) { } public static enum Format { grouped , simple ; } public static enum TotalCount { grouped , ungrouped ; } public abstract class Command < GROUP_VALUE_TYPE > { public String key ; public Sort groupSort ; public Sort sort ; public int docsPerGroup ; public int groupOffset ; public int numGroups ; int actualGroupsToFind ; public int offset ; public Grouping . Format format ; public boolean main ; public Grouping . TotalCount totalCount = Grouping . TotalCount . ungrouped ; TopGroups < GROUP_VALUE_TYPE > result ; protected abstract void prepare ( ) throws IOException { } protected abstract Collector createFirstPassCollector ( ) throws IOException { } protected Collector createSecondPassCollector ( ) throws IOException { } public AbstractAllGroupHeadsCollector < ? > createAllGroupCollector ( ) throws IOException { } protected abstract void finish ( ) throws IOException ; public abstract int getMatches ( ) { } protected Integer getNumberOfGroups ( ) { } protected NamedList commonResponse ( ) { } protected DocList getDocList ( GroupDocs groups ) { } protected void addDocList ( NamedList rsp , GroupDocs groups ) { } protected DocList createSimpleResponse ( ) { } } public class CommandField extends Grouping . Command < BytesRef > { public String groupBy ; TermFirstPassGroupingCollector firstPass ; TermSecondPassGroupingCollector secondPass ; TermAllGroupsCollector allGroupsCollector ; TotalHitCountCollector fallBackCollector ; Collection < SearchGroup < BytesRef > > topGroups ; protected void prepare ( ) throws IOException { } protected Collector createFirstPassCollector ( ) throws IOException { } protected Collector createSecondPassCollector ( ) throws IOException { } @ Override public AbstractAllGroupHeadsCollector < ? > createAllGroupCollector ( ) throws IOException { } protected void finish ( ) throws IOException { result = ( ( secondPass ) != null ) ? secondPass . getTopGroups ( 0 ) : null ; if ( main ) { mainResult = createSimpleResponse ( ) ; return ; } NamedList groupResult = commonResponse ( ) ; if ( ( format ) == ( Grouping . Format . simple ) ) { groupResult . add ( "doclist" , createSimpleResponse ( ) ) ; return ; } List groupList = new ArrayList ( ) ; groupResult . add ( "groups" , groupList ) ; if ( ( result ) == null ) { return ; } if ( ( numGroups ) == 0 ) return ; for ( GroupDocs < BytesRef > group : result . groups ) { NamedList nl = new SimpleOrderedMap ( ) ; groupList . add ( nl ) ; if ( ( group . groupValue ) != null ) { SchemaField schemaField = searcher . getSchema ( ) . getField ( groupBy ) ; FieldType fieldType = schemaField . getType ( ) ; String readableValue = fieldType . indexedToReadable ( group . groupValue . utf8ToString ( ) ) ; IndexableField field = schemaField . createField ( readableValue , 0.0F ) ; nl . add ( "groupValue" , fieldType . toObject ( field ) ) ; } else { nl . add ( "groupValue" , null ) ; } addDocList ( nl , group ) ; } } public int getMatches ( ) { } protected Integer getNumberOfGroups ( ) { } } public class CommandQuery extends Grouping . Command { public Query query ; TopDocsCollector topCollector ; FilterCollector collector ; protected void prepare ( ) throws IOException { } protected Collector createFirstPassCollector ( ) throws IOException { } TopDocsCollector newCollector ( Sort sort , boolean needScores ) throws IOException { } protected void finish ( ) throws IOException { TopDocsCollector topDocsCollector = ( ( TopDocsCollector ) ( collector . getDelegate ( ) ) ) ; TopDocs topDocs = topDocsCollector . topDocs ( ) ; <START_BUG> GroupDocs < String > groupDocs = new GroupDocs < String > ( topDocs . getMaxScore ( ) , topDocs . totalHits , topDocs . scoreDocs , query . toString ( ) , null ) ; <END_BUG> if ( main ) { mainResult = getDocList ( groupDocs ) ; } else { NamedList rsp = commonResponse ( ) ; addDocList ( rsp , groupDocs ) ; } } public int getMatches ( ) { } } public class CommandFunc extends Grouping . Command < MutableValue > { public ValueSource groupBy ; Map context ; FunctionFirstPassGroupingCollector firstPass ; FunctionSecondPassGroupingCollector secondPass ; TotalHitCountCollector fallBackCollector ; FunctionAllGroupsCollector allGroupsCollector ; Collection < SearchGroup < MutableValue > > topGroups ; protected void prepare ( ) throws IOException { } protected Collector createFirstPassCollector ( ) throws IOException { } protected Collector createSecondPassCollector ( ) throws IOException { } @ Override public AbstractAllGroupHeadsCollector < ? > createAllGroupCollector ( ) throws IOException { } protected void finish ( ) throws IOException { result = ( ( secondPass ) != null ) ? secondPass . getTopGroups ( 0 ) : null ; if ( main ) { mainResult = createSimpleResponse ( ) ; return ; } NamedList groupResult = commonResponse ( ) ; if ( ( format ) == ( Grouping . Format . simple ) ) { groupResult . add ( "doclist" , createSimpleResponse ( ) ) ; return ; } List groupList = new ArrayList ( ) ; groupResult . add ( "groups" , groupList ) ; if ( ( result ) == null ) { return ; } if ( ( numGroups ) == 0 ) return ; for ( GroupDocs < MutableValue > group : result . groups ) { NamedList nl = new SimpleOrderedMap ( ) ; groupList . add ( nl ) ; nl . add ( "groupValue" , group . groupValue . toObject ( ) ) ; addDocList ( nl , group ) ; } } public int getMatches ( ) { } protected Integer getNumberOfGroups ( ) { }

Fix:
GroupDocs < String > groupDocs = new GroupDocs < String > ( Float . NaN , topDocs . getMaxScore ( ) , topDocs . totalHits , topDocs . scoreDocs , query . toString ( ) , null ) ;