You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kafka.apache.org by ij...@apache.org on 2022/08/14 19:54:42 UTC
[kafka] branch trunk updated: MINOR: Cleanup NetworkReceive constructors (#12511)
This is an automated email from the ASF dual-hosted git repository.
ijuma pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git
The following commit(s) were added to refs/heads/trunk by this push:
new 91c23a3b938 MINOR: Cleanup NetworkReceive constructors (#12511)
91c23a3b938 is described below
commit 91c23a3b9383cdaff32e97a7dcca07e13532e032
Author: Ismael Juma <is...@juma.me.uk>
AuthorDate: Sun Aug 14 12:54:20 2022 -0700
MINOR: Cleanup NetworkReceive constructors (#12511)
There was unnecessary duplication and one of the overloads
did not set the size field for no good reason.
Reviewers: Luke Chen <sh...@gmail.com>
---
.../apache/kafka/common/network/NetworkReceive.java | 21 +++++----------------
1 file changed, 5 insertions(+), 16 deletions(-)
diff --git a/clients/src/main/java/org/apache/kafka/common/network/NetworkReceive.java b/clients/src/main/java/org/apache/kafka/common/network/NetworkReceive.java
index 5332c8109f3..b1c71abd699 100644
--- a/clients/src/main/java/org/apache/kafka/common/network/NetworkReceive.java
+++ b/clients/src/main/java/org/apache/kafka/common/network/NetworkReceive.java
@@ -30,8 +30,8 @@ import java.nio.channels.ScatteringByteChannel;
*/
public class NetworkReceive implements Receive {
- public final static String UNKNOWN_SOURCE = "";
- public final static int UNLIMITED = -1;
+ public static final String UNKNOWN_SOURCE = "";
+ public static final int UNLIMITED = -1;
private static final Logger log = LoggerFactory.getLogger(NetworkReceive.class);
private static final ByteBuffer EMPTY_BUFFER = ByteBuffer.allocate(0);
@@ -44,27 +44,16 @@ public class NetworkReceive implements Receive {
public NetworkReceive(String source, ByteBuffer buffer) {
- this.source = source;
+ this(UNLIMITED, source);
this.buffer = buffer;
- this.size = null;
- this.maxSize = UNLIMITED;
- this.memoryPool = MemoryPool.NONE;
}
public NetworkReceive(String source) {
- this.source = source;
- this.size = ByteBuffer.allocate(4);
- this.buffer = null;
- this.maxSize = UNLIMITED;
- this.memoryPool = MemoryPool.NONE;
+ this(UNLIMITED, source);
}
public NetworkReceive(int maxSize, String source) {
- this.source = source;
- this.size = ByteBuffer.allocate(4);
- this.buffer = null;
- this.maxSize = maxSize;
- this.memoryPool = MemoryPool.NONE;
+ this(maxSize, source, MemoryPool.NONE);
}
public NetworkReceive(int maxSize, String source, MemoryPool memoryPool) {