question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AssertionError in Channel.config().getOptions() when nio is used

See original GitHub issue

After migrating from 4.1.27.Final to 4.1.28.Final the following error appeared

Expected behavior

no errors

Actual behavior

java.lang.AssertionError: Option not found

	at sun.nio.ch.Net.getSocketOption(Net.java:360)
	at sun.nio.ch.ServerSocketChannelImpl.getOption(ServerSocketChannelImpl.java:177)
	at io.netty.channel.socket.nio.NioChannelOption.getOption(NioChannelOption.java:65)
	at io.netty.channel.socket.nio.NioServerSocketChannel$NioServerSocketChannelConfig.getOption(NioServerSocketChannel.java:216)
	at io.netty.channel.DefaultChannelConfig.getOptions(DefaultChannelConfig.java:94)
	at io.netty.channel.socket.nio.NioServerSocketChannel$NioServerSocketChannelConfig.getOptions(NioServerSocketChannel.java:225)
	at NettyNioChannelGetOptions.test(NettyNioChannelGetOptions.java:36)

Steps to reproduce

run below test

Minimal yet complete reproducer code (or URL to code)

import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import org.junit.Test;

import java.net.InetSocketAddress;
import java.net.SocketAddress;

public class NettyNioChannelGetOptions {

    @Test
    public void test() throws InterruptedException {
        ServerBootstrap bootstrap = new ServerBootstrap().
            group(new NioEventLoopGroup(1), new NioEventLoopGroup(1)).
            channel(NioServerSocketChannel.class).
            childHandler(new ChannelHandler() {
                @Override
                public void handlerAdded(ChannelHandlerContext ctx) {
                }

                @Override
                public void handlerRemoved(ChannelHandlerContext ctx) {
                }

                @Override
                public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
                }
            });
        SocketAddress address = new InetSocketAddress("0.0.0.0", 18389);
        Channel channel = bootstrap.bind(address).sync().channel();
        channel.config().getOptions(); // throws java.lang.AssertionError: Option not found
        channel.close();
    }
}

Netty version

4.1.28.Final

JVM version (e.g. java -version)

java version "1.8.0_161"
Java(TM) SE Runtime Environment (build 1.8.0_161-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode)

OS version (e.g. uname -a)

OS X El Capitan 10.11.6 Darwin xxx 15.6.0 Darwin Kernel Version 15.6.0: Thu Jun 21 20:07:40 PDT 2018; root:xnu-3248.73.11~1/RELEASE_X86_64 x86_64

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
normanmaurercommented, Aug 9, 2018
1reaction
normanmaurercommented, Aug 8, 2018

Here is a PR with a workaround: https://github.com/netty/netty/pull/8183

Read more comments on GitHub >

github_iconTop Results From Across the Web

Java Examples for io.netty.channel.socket.nio ... - Javatips.net
This java examples will help you to understand the usage of io.netty.channel.socket.nio.NioSocketChannel. These source code samples are taken from different ...
Read more >
RemoteInput - Android Developers
Returns true if the input only accepts data, meaning getAllowFreeFormInput() is false, getChoices() is null or empty, and getAllowedDataTypes() is non-null ...
Read more >
AppConfigurationEntry (Java Platform SE 6)
getOptions(). Get the options configured for this LoginModule . Returns: the options configured for this LoginModule as an unmodifiable Map .
Read more >
io.grpc.netty.Utils.java Source code - Java2s.com
NioEventLoopGroup ; import io.netty.channel.socket.nio. ... not just ASCII. byte[][] headerValues = new byte[http2Headers.size() * 2][]; int i = 0; for (Map.
Read more >
Diff - external/junit - Google Git
Format your code: Import the JUnit project in Eclipse and use its formatter ... Derived from the _tokenize() subroutine from Brad Choate's MTRegex...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found