Buggy code:
public class GroupedEndResultTransformer implements EndResultTransformer { private final SolrIndexSearcher searcher ; public GroupedEndResultTransformer ( SolrIndexSearcher searcher ) { } @ Override public void transform ( Map < String , ? > result , ResponseBuilder rb , SolrDocumentSource solrDocumentSource ) { <START_BUG> NamedList < Object > commands = new NamedList < Object > ( ) ; <END_BUG> for ( Map . Entry < String , ? > entry : result . entrySet ( ) ) { Object value = entry . getValue ( ) ; if ( TopGroups . class . isInstance ( value ) ) { @ SuppressWarnings ( "unchecked" ) TopGroups < BytesRef > topGroups = ( ( TopGroups < BytesRef > ) ( value ) ) ; NamedList < Object > command = new org . apache . solr . common . util . SimpleOrderedMap < Object > ( ) ; command . add ( "matches" , rb . totalHitCount ) ; Integer totalGroupCount = rb . mergedGroupCounts . get ( entry . getKey ( ) ) ; if ( totalGroupCount != null ) { command . add ( "ngroups" , totalGroupCount ) ; } List < NamedList > groups = new ArrayList < NamedList > ( ) ; SchemaField groupField = searcher . getSchema ( ) . getField ( entry . getKey ( ) ) ; FieldType groupFieldType = groupField . getType ( ) ; for ( GroupDocs < BytesRef > group : topGroups . groups ) { org . apache . solr . common . util . SimpleOrderedMap < Object > groupResult = new org . apache . solr . common . util . SimpleOrderedMap < Object > ( ) ; if ( ( group . groupValue ) != null ) { groupResult . add ( "groupValue" , groupFieldType . toObject ( groupField . createField ( group . groupValue . utf8ToString ( ) , 1.0F ) ) ) ; } else { groupResult . add ( "groupValue" , null ) ; } SolrDocumentList docList = new SolrDocumentList ( ) ; docList . setNumFound ( group . totalHits ) ; if ( ! ( Float . isNaN ( group . maxScore ) ) ) { docList . setMaxScore ( group . maxScore ) ; } docList . setStart ( rb . getGroupingSpec ( ) . getGroupOffset ( ) ) ; for ( ScoreDoc scoreDoc : group . scoreDocs ) { docList . add ( solrDocumentSource . retrieve ( scoreDoc ) ) ; } groupResult . add ( "doclist" , docList ) ; groups . add ( groupResult ) ; } command . add ( "groups" , groups ) ; commands . add ( entry . getKey ( ) , command ) ; } else if ( QueryCommandResult . class . isInstance ( value ) ) { QueryCommandResult queryCommandResult = ( ( QueryCommandResult ) ( value ) ) ; NamedList < Object > command = new org . apache . solr . common . util . SimpleOrderedMap < Object > ( ) ; command . add ( "matches" , queryCommandResult . getMatches ( ) ) ; SolrDocumentList docList = new SolrDocumentList ( ) ; docList . setNumFound ( queryCommandResult . getTopDocs ( ) . totalHits ) ; if ( ! ( Float . isNaN ( queryCommandResult . getTopDocs ( ) . getMaxScore ( ) ) ) ) { docList . setMaxScore ( queryCommandResult . getTopDocs ( ) . getMaxScore ( ) ) ; } docList . setStart ( rb . getGroupingSpec ( ) . getGroupOffset ( ) ) ; for ( ScoreDoc scoreDoc : queryCommandResult . getTopDocs ( ) . scoreDocs ) { docList . add ( solrDocumentSource . retrieve ( scoreDoc ) ) ; } command . add ( "doclist" , docList ) ; commands . add ( entry . getKey ( ) , command ) ; } } rb . rsp . add ( "grouped" , commands ) ; } }

Fix:
NamedList < Object > commands = new org . apache . solr . common . util . SimpleOrderedMap < Object > ( ) ;