Netty: Java 9: Netty doesnt work in vertx.io (problems with direct buffers)

Created on 15 Oct 2017  路  4Comments  路  Source: netty/netty

Expected behavior

No warnings.

Actual behavior

Stacktrace:

Okt. 15, 2017 12:04:34 VORM. io.netty.util.internal.PlatformDependent <clinit>
INFORMATION: Your platform does not provide complete low-level API for accessing direct buffers reliably. Unless explicitly requested, heap buffer will always be preferred to avoid potential system unstability.
Okt. 15, 2017 12:04:35 VORM. io.netty.resolver.dns.DnsServerAddresses <clinit>
WARNUNG: Default DNS servers: [/8.8.8.8:53, /8.8.4.4:53] (Google Public DNS as a fallback)
Okt. 15, 2017 12:04:35 VORM. io.netty.channel.DefaultChannelId defaultProcessId
WARNUNG: Failed to find the current process ID from ''; using a random value: -1210910476

Steps to reproduce

Use vert.x and create an NetServer.

Minimal yet complete reproducer code (or URL to code)

public class Server {

    //vert.x options
    protected VertxOptions vertxOptions = null;

    //instance of vert.x
    protected Vertx vertx = null;

    //vert.x network server
    protected NetServer netServer = null;

    public void start() {
        //create new vertx.io options
        this.vertxOptions = new VertxOptions();

        //create new instance of vertx.io
        this.vertx = Vertx.vertx(this.vertxOptions);

        //create options for TCP network server
        NetServerOptions netServerOptions = new NetServerOptions();

        //TODO: replace this later
        int port = 2200;

        //set port
        netServerOptions.setPort(port);

        //create new instance of TCP network server
        this.netServer = this.vertx.createNetServer(netServerOptions);

        //add connection handler
        netServer.connectHandler(socket -> {
            System.out.println("new connection accepted, ip: " + socket.remoteAddress().host() + ", port: " + socket.remoteAddress().port());

            //TODO: do something with socket, for example send an message
        });

        //start network server
        this.netServer.listen(res -> {
            if (res.succeeded()) {
                System.out.println("ERP Server is now listening on port " + res.result().actualPort());
            } else {
                System.err.println("Couldnt start network server: " + res.cause());
            }
        });
    }

    public void stutdown() {
        //close network server
        netServer.close(res -> {
            if (res.succeeded()) {
                System.out.println("Server was shutdown now.");

                //close vertx.io
                vertx.close();
            } else {
                System.out.println("Server couldnt be closed.");
            }
        });
    }

}

Netty version

Unknown - because i use newest vert.x version (vert.x version 3.4.2).

JVM version (e.g. java -version)

Java Version 1.9 (Oracle JDK)

OS version (e.g. uname -a)

Windows 10

All 4 comments

This was fixed in netty recently. The version of vert.x is using netty 4.1.8.Final which is really old and not has the fix. Please upgrade:

https://github.com/eclipse/vert.x/blob/3.4.2/pom.xml#L51

@normanmaurer it's inclear which version of netty fixed that ?

@vietj there are a few different fixes but I think the one that is linked from the vert.x issue would be 4.1.9.Final:

https://github.com/netty/netty/commit/90bc60547784877366a3294e6b945a5241b7099f#diff-5a0bcc32d9866d6c36a3358082cc5f44

That said we did multiple fixes related to java9. The latest release should work just fine with java9

@normanmaurer I have updated to newest vertx version (3.5.0) with netty 4.1.15.
But the warnings still occurs.

Here is the new log:

WARNING: Illegal reflective access by io.netty.util.internal.ReflectionUtil (file:/D:/Users/Justin/.m2/repository/io/netty/netty-common/4.1.15.Final/netty-common-4.1.15.Final.jar) to field sun.nio.ch.SelectorImpl.selectedKeys
WARNING: Illegal reflective access by io.netty.util.internal.ReflectionUtil (file:/D:/Users/Justin/.m2/repository/io/netty/netty-common/4.1.15.Final/netty-common-4.1.15.Final.jar) to field sun.nio.ch.SelectorImpl.publicSelectedKeys
WARNING: Illegal reflective access by io.netty.util.internal.ReflectionUtil (file:/D:/Users/Justin/.m2/repository/io/netty/netty-common/4.1.15.Final/netty-common-4.1.15.Final.jar) to field sun.nio.ch.SelectorImpl.selectedKeys
WARNING: Illegal reflective access by io.netty.util.internal.ReflectionUtil (file:/D:/Users/Justin/.m2/repository/io/netty/netty-common/4.1.15.Final/netty-common-4.1.15.Final.jar) to field sun.nio.ch.SelectorImpl.publicSelectedKeys
[9.298s][info][gc] GC(5) Pause Young (G1 Evacuation Pause) 81M->19M(128M) 12.039ms
WARNING: Illegal reflective access by io.netty.resolver.dns.DnsNameResolver (file:/D:/Users/Justin/.m2/repository/io/netty/netty-resolver-dns/4.1.15.Final/netty-resolver-dns-4.1.15.Final.jar) to method sun.net.dns.ResolverConfiguration.open()
WARNING: Illegal reflective access by io.netty.resolver.dns.DnsNameResolver (file:/D:/Users/Justin/.m2/repository/io/netty/netty-resolver-dns/4.1.15.Final/netty-resolver-dns-4.1.15.Final.jar) to method sun.net.dns.ResolverConfiguration.searchlist()
Was this page helpful?
0 / 5 - 0 ratings

Related issues

gliwka picture gliwka  路  3Comments

normanmaurer picture normanmaurer  路  3Comments

pengzhengfa picture pengzhengfa  路  3Comments

codekrolik picture codekrolik  路  5Comments

JuKu picture JuKu  路  4Comments