Fix name of combining filtered aggregator factory. (#16224)

The name of the combining filtered aggregator factory should be the same
as the name of the original factory. However, it wasn't the same in the
case where the original factory's name and the original delegate aggregator
were inconsistently named. In this scenario, we should use the name of
the original filtered aggregator, not the name of the original delegate
aggregator.
This commit is contained in:
Gian Merlino 2024-04-02 12:59:48 -07:00 committed by GitHub
parent 9b52c909e0
commit b0ca06f8cd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 28 additions and 1 deletions

View File

@ -139,7 +139,14 @@ public class FilteredAggregatorFactory extends AggregatorFactory
@Override @Override
public AggregatorFactory getCombiningFactory() public AggregatorFactory getCombiningFactory()
{ {
return delegate.getCombiningFactory(); final AggregatorFactory delegateCombiningFactory = delegate.getCombiningFactory();
final String myName = getName();
if (myName.equals(delegateCombiningFactory.getName())) {
return delegateCombiningFactory;
} else {
return delegateCombiningFactory.withName(myName);
}
} }
@Override @Override

View File

@ -48,6 +48,26 @@ public class FilteredAggregatorFactoryTest extends InitializedNullHandlingTest
).getName()); ).getName());
} }
@Test
public void testNameOfCombiningFactory()
{
Assert.assertEquals("overrideName", new FilteredAggregatorFactory(
new CountAggregatorFactory("foo"),
TrueDimFilter.instance(),
"overrideName"
).getCombiningFactory().getName());
Assert.assertEquals("delegateName", new FilteredAggregatorFactory(
new CountAggregatorFactory("delegateName"),
TrueDimFilter.instance(),
""
).getCombiningFactory().getName());
Assert.assertEquals("delegateName", new FilteredAggregatorFactory(
new CountAggregatorFactory("delegateName"),
TrueDimFilter.instance(),
null
).getCombiningFactory().getName());
}
@Test @Test
public void testRequiredFields() public void testRequiredFields()
{ {