Is it possible to write to Netty channel without creating unnecessary ChannelFuture? (Without generating unnecessary object for GC…)
Is it possible to write to Netty channel without creating unnecessary ChannelFuture? (Without generating
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you really wish you don’t want to create a
ChannelFuture, you can do this for Netty 3:Channels.succeededFuture(..)returns a channel-local singleton object. However, you should never add a listener to the returned future because it’s already complete.In Netty 4, you can use void promise:
ChannelHandlerContext.voidPromise()returns a dummy singleton promise which is never fulfilled. The operations like adding a listener or waiting until it is fulfilled will fail immediately.