Skip to content

Commit

Permalink
Fix name of combining filtered aggregator factory. (#16224)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
gianm authored Apr 2, 2024
1 parent 9b52c90 commit b0ca06f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,14 @@ public AggregateCombiner makeAggregateCombiner()
@Override
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,26 @@ public void testSimpleNaming()
).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
public void testRequiredFields()
{
Expand Down

0 comments on commit b0ca06f

Please sign in to comment.