Skip to content

Commit ad19bdc

Browse files
committed
Use removeEach to clean up unsettled map
1 parent c051d4d commit ad19bdc

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/main/qpid/org/apache/qpid/protonj2/engine/impl/ProtonReceiver.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.util.Collections;
2222
import java.util.List;
2323
import java.util.Objects;
24+
import java.util.function.Consumer;
2425
import java.util.function.Predicate;
2526

2627
import org.apache.qpid.protonj2.buffer.ProtonBuffer;
@@ -46,6 +47,12 @@
4647
*/
4748
public class ProtonReceiver extends ProtonLink<Receiver> implements Receiver {
4849

50+
private static final Consumer<ProtonIncomingDelivery> RELEASE_INCOMING_DELIVERY_TAG_CALLBACK = d -> {
51+
if (d.getTag() != null) {
52+
d.getTag().release();
53+
}
54+
};
55+
4956
private EventHandler<IncomingDelivery> deliveryReadEventHandler = null;
5057
private EventHandler<IncomingDelivery> deliveryAbortedEventHandler = null;
5158
private EventHandler<IncomingDelivery> deliveryUpdatedEventHandler = null;
@@ -243,10 +250,7 @@ public void disposition(DeliveryState state, long[] range) {
243250
try {
244251
sessionWindow.processDisposition(state, range);
245252
} finally {
246-
for (long i = range[0]; i < range[1]; i++) {
247-
unsettled.remove((int) i);
248-
}
249-
// TODO release delivery tags
253+
unsettled.removeEach((int) range[0], (int) range[1], RELEASE_INCOMING_DELIVERY_TAG_CALLBACK);
250254
}
251255
}
252256

src/main/qpid/org/apache/qpid/protonj2/engine/impl/ProtonSessionIncomingWindow.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,9 +232,7 @@ void processDisposition(ProtonReceiver receiver, ProtonIncomingDelivery delivery
232232
}
233233

234234
void processDisposition(DeliveryState state, long [] range) {
235-
for (long i = range[0]; i < range[1]; i++) {
236-
unsettled.remove((int) i);
237-
}
235+
unsettled.removeEach((int) range[0], (int) range[1], d -> { });
238236
cachedDisposition.reset();
239237
cachedDisposition.setFirst(range[0]);
240238
cachedDisposition.setLast(range[1]);

0 commit comments

Comments
 (0)