From 3c0780b852371025b97fb3212a68fca1f7ed9c3b Mon Sep 17 00:00:00 2001 From: Tobias Lindaaker Date: Tue, 5 Jul 2022 18:07:48 +0200 Subject: [PATCH] Fix typo in KQueueChannelConfig (#12537) Motivation: KQueueChannelConfigTest.testRawOption() fails on MacOS due to the buffer for the RawUnixChannelOption being over-allocated when retrieving the option value. Since the limit is not explicitly set (the buffer is just flipped), the limit of the buffer will be based on its size, causing the test to fail. Modification: Changes the buffer allocation for getOption of RawUnixChannelOption in KQueueChannelConfig to be based on the length of the option instead of the level. The use of level is likely a typo. The corresponding code in EpollChannelConfig allocates the buffer based on length rather than level. Result: One less test failure when building on MacOS (Intel) with JDK 1.8. --- .../main/java/io/netty/channel/kqueue/KQueueChannelConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/transport-classes-kqueue/src/main/java/io/netty/channel/kqueue/KQueueChannelConfig.java b/transport-classes-kqueue/src/main/java/io/netty/channel/kqueue/KQueueChannelConfig.java index 4f5ff99e3c4..e3d870c6137 100644 --- a/transport-classes-kqueue/src/main/java/io/netty/channel/kqueue/KQueueChannelConfig.java +++ b/transport-classes-kqueue/src/main/java/io/netty/channel/kqueue/KQueueChannelConfig.java @@ -67,7 +67,7 @@ public T getOption(ChannelOption option) { } if (option instanceof RawUnixChannelOption) { RawUnixChannelOption opt = (RawUnixChannelOption) option; - ByteBuffer out = ByteBuffer.allocate(opt.level()); + ByteBuffer out = ByteBuffer.allocate(opt.length()); ((AbstractKQueueChannel) channel).socket.getRawOpt(opt.level(), opt.optname(), out); return (T) out.flip(); }