[
https://issues.apache.org/jira/browse/KAFKA-6716?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16417372#comment-16417372
]
ASF GitHub Bot commented on KAFKA-6716:
---
rajinisivaram closed pull request #4783: KAFKA-6716: Should close the
`discardChannel` in completeSend
URL: https://github.com/apache/kafka/pull/4783
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/clients/src/test/java/org/apache/kafka/test/MockSelector.java
b/clients/src/test/java/org/apache/kafka/test/MockSelector.java
index bd27d5c6d99..200d5111517 100644
--- a/clients/src/test/java/org/apache/kafka/test/MockSelector.java
+++ b/clients/src/test/java/org/apache/kafka/test/MockSelector.java
@@ -124,11 +124,12 @@ private void completeInitiatedSends() throws IOException {
private void completeSend(Send send) throws IOException {
// Consume the send so that we will be able to send more requests to
the destination
-ByteBufferChannel discardChannel = new ByteBufferChannel(send.size());
-while (!send.completed()) {
-send.writeTo(discardChannel);
+try (ByteBufferChannel discardChannel = new
ByteBufferChannel(send.size())) {
+while (!send.completed()) {
+send.writeTo(discardChannel);
+}
+completedSends.add(send);
}
-completedSends.add(send);
}
private void completeDelayedReceives() {
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org
> discardChannel should be released in MockSelector#completeSend
> --
>
> Key: KAFKA-6716
> URL: https://issues.apache.org/jira/browse/KAFKA-6716
> Project: Kafka
> Issue Type: Test
>Reporter: Ted Yu
>Assignee: huxihx
>Priority: Minor
>
> {code}
> private void completeSend(Send send) throws IOException {
> // Consume the send so that we will be able to send more requests to
> the destination
> ByteBufferChannel discardChannel = new ByteBufferChannel(send.size());
> while (!send.completed()) {
> send.writeTo(discardChannel);
> }
> completedSends.add(send);
> }
> {code}
> The {{discardChannel}} should be closed before returning from the method
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)