Skip to content

Commit

Permalink
Fix typo in KQueueChannelConfig (#12537)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
thobe committed Jul 5, 2022
1 parent 985971e commit 29b203f
Showing 1 changed file with 1 addition and 1 deletion.
Expand Up @@ -67,7 +67,7 @@ public <T> T getOption(ChannelOption<T> 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();
}
Expand Down

0 comments on commit 29b203f

Please sign in to comment.