NetworkChannel.getOption(...) throws java.lang.AssertionError: Option not found
Norman Maurer
norman.maurer at googlemail.com
Wed Aug 8 17:18:42 UTC 2018
Hi,
I just wanted to double check that I am not doing something wrong here.
This code will throw an java.lang.AssertionError: Option not found :
public static void main(String[] args) throws IOException {
getAllSupportedOptions(DatagramChannel.open());
getAllSupportedOptions(SocketChannel.open());
getAllSupportedOptions(ServerSocketChannel.open());
}
private static void getAllSupportedOptions(NetworkChannel channel) throws IOException {
try {
for (SocketOption<?> option : channel.supportedOptions()) {
channel.getOption(option);
}
} finally {
channel.close();
}
}
It throws for ServerSocketChannel. The option that throws here is IP_TOS which is returned by supportedOptions().
We recently got this reported in netty where we make use of such a pattern:
https://github.com/netty/netty/issues/8182
If this sounds like a bug (I am very confident it is one) I can create an issue.
This happens on latest java8, 9, 10 and 11 on MacOS. I did not test Linux yet.
As a side-note it would be nice if the AssertionError would have included the option for which it throws.
Thanks,
Norman
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/nio-dev/attachments/20180808/75ee9962/attachment-0001.html>
More information about the nio-dev
mailing list