From ac2d3cd400cd94c8cf05dcd60d8e0b574e8feeed Mon Sep 17 00:00:00 2001 From: Trustin Lee Date: Thu, 10 Dec 2015 16:48:18 +0900 Subject: [PATCH] Fix a leak in an HTTP/2 connection HttpSessionHandler.MultiplexWaitsHolder.poll() does not remove the polled request, causing a leak. Also, replaced LinkedList with ArrayDeque for better performance and memory usage --- .../com/linecorp/armeria/client/HttpSessionHandler.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/linecorp/armeria/client/HttpSessionHandler.java b/src/main/java/com/linecorp/armeria/client/HttpSessionHandler.java index 87cffdcd5dd..3e9e5fca3e4 100644 --- a/src/main/java/com/linecorp/armeria/client/HttpSessionHandler.java +++ b/src/main/java/com/linecorp/armeria/client/HttpSessionHandler.java @@ -17,8 +17,8 @@ import static java.util.Objects.requireNonNull; +import java.util.ArrayDeque; import java.util.Collection; -import java.util.LinkedList; import java.util.Queue; import com.linecorp.armeria.common.SerializationFormat; @@ -180,7 +180,7 @@ private static class SequentialWaitsHolder implements WaitsHolder { private final Queue> requestExpectQueue; SequentialWaitsHolder() { - requestExpectQueue = new LinkedList<>(); + requestExpectQueue = new ArrayDeque<>(); } @Override @@ -216,7 +216,7 @@ private static class MultiplexWaitsHolder implements WaitsHolder { @Override public Promise poll(FullHttpResponse response) { int streamID = response.headers().getInt(ExtensionHeaderNames.STREAM_ID.text(), 0); - return resultExpectMap.get(streamID); + return resultExpectMap.remove(streamID); } @Override