The attached patch has some quick and dirty tests demonstraitng these problems as well as my porposed fix.
Rather then slap a bandaid on this i did a pretty serious overhaul of the way the code in StatsComponent is laid out. This not only fixes the bug by consolidating the param parsing logic into a single place, it helps ensure param descrepencies like won't pop up as we add features (by consolidating the param parsing logic into a single place), and it moves the direction i want to move for features like
SOLR-6354 & SOLR-6351.
- StatsInfo is now used for both for both distributed & local requests
- still one instance per request
- SimpleFacets has been renamed/refactored into "StatsField"
- now only models a single "stats.field" param (no more "iterating" local state variables)
- API is now a lot more locked down and easier to understand (in my opinion)
- code that dealt with multiple "stats.field" params bubbled up to either StatsInfo or the process() method of StatsComponent
There's still plenty of nocommits – mostly dealing with javadocs and more robust tests, but i think this is a good start in the right direction.