Skip to content

Commit 2b29b5e

Browse files
authored
Use exact length when allocating the acceptedAddress byte[] (#15973) (#15984)
Motivation: We used some odd number for the length, just use the exact length that we need. Modifications: - Allocate a byte[] of 25 length and remove odd comment Result: Cleanup
1 parent b1182ed commit 2b29b5e

2 files changed

Lines changed: 2 additions & 4 deletions

File tree

‎transport-classes-epoll/src/main/java/io/netty/channel/epoll/AbstractEpollServerChannel.java‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@ protected Object filterOutboundMessage(Object msg) throws Exception {
7171
final class EpollServerSocketUnsafe extends AbstractEpollUnsafe {
7272
// Will hold the remote address after accept(...) was successful.
7373
// We need 24 bytes for the address as maximum + 1 byte for storing the length.
74-
// So use 26 bytes as it's a power of two.
75-
private final byte[] acceptedAddress = new byte[26];
74+
private final byte[] acceptedAddress = new byte[25];
7675

7776
@Override
7877
public void connect(SocketAddress socketAddress, SocketAddress socketAddress2, ChannelPromise channelPromise) {

‎transport-classes-kqueue/src/main/java/io/netty/channel/kqueue/AbstractKQueueServerChannel.java‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@ protected boolean doConnect(SocketAddress remoteAddress, SocketAddress localAddr
7171
final class KQueueServerSocketUnsafe extends AbstractKQueueUnsafe {
7272
// Will hold the remote address after accept(...) was successful.
7373
// We need 24 bytes for the address as maximum + 1 byte for storing the capacity.
74-
// So use 26 bytes as it's a power of two.
75-
private final byte[] acceptedAddress = new byte[26];
74+
private final byte[] acceptedAddress = new byte[25];
7675

7776
@Override
7877
void readReady(KQueueRecvByteAllocatorHandle allocHandle) {

0 commit comments

Comments
 (0)