From 568dae0341285cfff02a226ede093a81375afe2f Mon Sep 17 00:00:00 2001 From: Rajini Sivaram Date: Thu, 7 Mar 2019 18:09:50 +0000 Subject: [PATCH] KAFKA-7288 - Make sure no bytes buffered when relying on idle timeout in channel close test (#6390) SelectorTest.testCloseConnectionInClosingState sends and receives messages to get the channel into a state with staged receives and then waits for idle timeout to close the channel. When run with SSL, the channel may have buffered bytes that prevent the channel from being closed. Updated the test to wait until there are no buffered bytes as well. Reviewers: Ismael Juma --- .../java/org/apache/kafka/common/network/SelectorTest.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/clients/src/test/java/org/apache/kafka/common/network/SelectorTest.java b/clients/src/test/java/org/apache/kafka/common/network/SelectorTest.java index cfd7fb3af8d12..b77d2784e5525 100644 --- a/clients/src/test/java/org/apache/kafka/common/network/SelectorTest.java +++ b/clients/src/test/java/org/apache/kafka/common/network/SelectorTest.java @@ -427,8 +427,10 @@ private KafkaChannel createConnectionWithStagedReceives(int maxStagedReceives) t do { selector.poll(1000); } while (selector.completedReceives().isEmpty()); - } while (selector.numStagedReceives(channel) == 0 && --retries > 0); + } while (selector.numStagedReceives(channel) == 0 && !channel.hasBytesBuffered() && --retries > 0); assertTrue("No staged receives after 100 attempts", selector.numStagedReceives(channel) > 0); + // We want to return without any bytes buffered to ensure that channel will be closed after idle time + assertFalse("Channel has bytes buffered", channel.hasBytesBuffered()); return channel; }