Usage of Async DNSResolver

67 views
Skip to first unread message

etienne....@gmail.com

unread,
Aug 22, 2017, 2:05:00 AM8/22/17
to Netty discussions
Hi,

I am trying to use the netty DnsNameResolver . I correctly achieved to use it with Future in the "sync way" (get / getNow method).
I am now trying to have it work in the "callback method". In order to do so, I added a specific promise which will add a listener . Example of code is here : https://gist.github.com/etiennecarriere/cec6b37dec05a1b5301d59ec190c456a
Currently, I have a NPE on internal netty class :
java.lang.NullPointerException
    at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:414) ~[netty-all-4.1.14.Final.jar:4.1.14.Final]
    at io.netty.util.concurrent.DefaultPromise.trySuccess(DefaultPromise.java:104) ~[netty-all-4.1.14.Final.jar:4.1.14.Final]
    at io.netty.resolver.dns.DnsQueryContext.setSuccess(DnsQueryContext.java:197) ~[netty-all-4.1.14.Final.jar:4.1.14.Final]
    at io.netty.resolver.dns.DnsQueryContext.finish(DnsQueryContext.java:180) ~[netty-all-4.1.14.Final.jar:4.1.14.Final]
    at io.netty.resolver.dns.DnsNameResolver$DnsResponseHandler.channelRead(DnsNameResolver.java:947) ~[netty-all-4.1.14.Final.jar:4.1.14.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [netty-all-4.1.14.Final.jar:4.1.14.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [netty-all-4.1.14.Final.jar:4.1.14.Final]
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [netty-all-4.1.14.Final.jar:4.1.14.Final]
    at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:102) [netty-all-4.1.14.Final.jar:4.1.14.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [netty-all-4.1.14.Final.jar:4.1.14.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [netty-all-4.1.14.Final.jar:4.1.14.Final]
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [netty-all-4.1.14.Final.jar:4.1.14.Final]
    at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1342) [netty-all-4.1.14.Final.jar:4.1.14.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [netty-all-4.1.14.Final.jar:4.1.14.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [netty-all-4.1.14.Final.jar:4.1.14.Final]
    at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:934) [netty-all-4.1.14.Final.jar:4.1.14.Final]
    at io.netty.channel.nio.AbstractNioMessageChannel$NioMessageUnsafe.read(AbstractNioMessageChannel.java:93) [netty-all-4.1.14.Final.jar:4.1.14.Final]
    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:645) [netty-all-4.1.14.Final.jar:4.1.14.Final]
    at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:580) [netty-all-4.1.14.Final.jar:4.1.14.Final]
    at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:497) [netty-all-4.1.14.Final.jar:4.1.14.Final]
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:459) [netty-all-4.1.14.Final.jar:4.1.14.Final]
    at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:858) [netty-all-4.1.14.Final.jar:4.1.14.Final]
    at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:138) [netty-all-4.1.14.Final.jar:4.1.14.Final]
    at java.lang.Thread.run(Thread.java:748) [?:1.8.0_131]

When put the code in debug, I see no missing/null attribute to DnsNameResolver. 

Thank you for your help,

Regards,

Etienne Carrière

Norman Maurer

unread,
Aug 22, 2017, 2:37:38 AM8/22/17
to ne...@googlegroups.com
Thats because you not specify the EventExecutor for the Promise. 

That said I am not sure why you not just add the listener to the returned Future ?


--
You received this message because you are subscribed to the Google Groups "Netty discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netty+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/netty/db52f8cb-0fba-4f36-94cd-2a129af008b5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages