List of usage examples for io.netty.channel ChannelPromise trySuccess
boolean trySuccess();
From source file:reactor.ipc.netty.channel.NettyOperations.java
License:Open Source License
/** * Callback when a writer {@link Subscriber} has effectively terminated listening * on further {@link Publisher} signals. * * @param ctx the actual {@link ChannelHandlerContext} * @param last an optional callback for the last written payload * @param promise the promise to fulfil for acknowledging termination success * @param exception non null if the writer has terminated with a failure *///from w ww . j a va 2s.com protected void doOnTerminatedWriter(ChannelHandlerContext ctx, ChannelFuture last, final ChannelPromise promise, final Throwable exception) { if (ctx.channel().isOpen()) { ChannelFutureListener listener = future -> { if (exception != null) { promise.tryFailure(exception); } else if (future.isSuccess()) { promise.trySuccess(); } else { promise.tryFailure(future.cause()); } }; if (last != null) { last.addListener(listener); ctx.flush(); } } else { if (exception != null) { promise.tryFailure(exception); } else { promise.trySuccess(); } } }