eclipse-vertx / vert.x

Vert.x is a tool-kit for building reactive applications on the JVM
http://vertx.io
Other
14.32k stars 2.08k forks source link

DNS client making request to non-existent DNS port returns java.net.PortUnreachableException which has no detail message #1755

Open InfoSec812 opened 7 years ago

InfoSec812 commented 7 years ago

Example:

vertx.createDnsClient(8053, '127.0.0.1').lookup('www.google.com', { res ->
    if (res.succeeded()) {
        LOG.info('SUCCESS')
    } else {
        LOG.error('FAILURE')
        LOG.error(res.cause().getLocalizedMessage()) // Returns NULL
    }
})
vietj commented 7 years ago

would you mind to set a break point in PortUnreachableException and see why there is no such message ?

InfoSec812 commented 7 years ago

PortUnreachableException has an available empty constructor which is being used by the underlying Netty library... Here's the call stack which leads to the Exception being created:

"vert.x-eventloop-thread-1@1858" prio=5 tid=0x14 nid=NA runnable
  java.lang.Thread.State: RUNNABLE
      at java.net.PortUnreachableException.<init>(PortUnreachableException.java:51)
      at sun.nio.ch.DatagramChannelImpl.receive0(DatagramChannelImpl.java:-1)
      at sun.nio.ch.DatagramChannelImpl.receiveIntoNativeBuffer(DatagramChannelImpl.java:414)
      at sun.nio.ch.DatagramChannelImpl.receive(DatagramChannelImpl.java:392)
      at sun.nio.ch.DatagramChannelImpl.receive(DatagramChannelImpl.java:345)
      - locked <0x868> (a java.lang.Object)
      at io.netty.channel.socket.nio.NioDatagramChannel.doReadMessages(NioDatagramChannel.java:248)
      at io.netty.channel.nio.AbstractNioMessageChannel$NioMessageUnsafe.read(AbstractNioMessageChannel.java:75)
      at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:610)
      at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:551)
      at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:465)
      at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:437)
      at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:873)
      at java.lang.Thread.run(Thread.java:745)

So, this appears to be a JDK or a Netty problem, not a Vert.x problem.

InfoSec812 commented 7 years ago

It might be a good idea for Vert.x to catch this and rethrow this with a proper detail message though.

vietj commented 7 years ago

@InfoSec812 it would be more appropriate to do it in Netty imho and reference it here.

InfoSec812 commented 7 years ago

Created https://github.com/netty/netty/issues/6179 to track in the Netty project.

vietj commented 7 years ago

thanks @InfoSec812

InfoSec812 commented 7 years ago

Got word back from Norman Mauer @normanmaurer that they will be updating https://github.com/netty/netty to catch and re-throw the exception because the problem is in the JavaSE standard lib.

vietj commented 7 years ago

@InfoSec812 great

InfoSec812 commented 7 years ago

Response from Norman was that they WILL be implementing a catch-rethrow for this condition and Normal has also raised a PR with OpenJDK to resolved this at that level as well.

vietj commented 7 years ago

@InfoSec812 have you checked if that's fixed in Netty ? we upgraded to version 4.1.8.Final in master

normanmaurer commented 7 years ago

@vietj not part of netty 4.1.8.Final