@@ -74,6 +74,7 @@ public final class AsynchronousMetricStorage<T extends PointData, U extends Exem
7474 private final ObjectPool <AggregatorHandle <T , U >> reusableHandlesPool ;
7575 private final Function <Attributes , AggregatorHandle <T , U >> handleBuilder ;
7676 private final BiConsumer <Attributes , AggregatorHandle <T , U >> handleReleaser ;
77+ private final BiConsumer <Attributes , T > pointReleaser ;
7778
7879 private final List <T > reusablePointsList = new ArrayList <>();
7980 // If aggregationTemporality == DELTA, this reference and lastPoints will be swapped at every
@@ -105,6 +106,7 @@ private AsynchronousMetricStorage(
105106 this .reusableHandlesPool = new ObjectPool <>(aggregator ::createHandle );
106107 this .handleBuilder = ignored -> reusableHandlesPool .borrowObject ();
107108 this .handleReleaser = (ignored , handle ) -> reusableHandlesPool .returnObject (handle );
109+ this .pointReleaser = (ignored , point ) -> reusablePointsPool .returnObject (point );
108110
109111 if (memoryMode == REUSABLE_DATA ) {
110112 this .lastPoints = new PooledHashMap <>();
@@ -273,7 +275,7 @@ private Collection<T> collectWithDeltaAggregationTemporality() {
273275 // lastPoints for the current collection can be discarded when the collection is completed.
274276 // They can be returned to the pool because they're not managed by the AggregatorHandle,
275277 // we made a copy.
276- lastPoints .forEach (( attributes , point ) -> reusablePointsPool . returnObject ( point ) );
278+ lastPoints .forEach (pointReleaser );
277279 lastPoints .clear ();
278280
279281 Map <Attributes , T > tmp = lastPoints ;
0 commit comments