Skip to content

Commit

Permalink
KAFKA-7288 - Make sure no bytes buffered when relying on idle timeout…
Browse files Browse the repository at this point in the history
… in channel close test (apache#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 <[email protected]>
  • Loading branch information
rajinisivaram authored and jonlee2 committed Mar 8, 2019
1 parent 51f156c commit 568dae0
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 568dae0

Please sign in to comment.