Java Code Examples for io.netty.channel.ChannelPromise#isVoid()

The following examples show how to use io.netty.channel.ChannelPromise#isVoid() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EmbeddedChannel.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
/**
 * Checks for the presence of an {@link Exception}.
 */
private ChannelFuture checkException(ChannelPromise promise) {
  Throwable t = lastException;
  if (t != null) {
    lastException = null;

    if (promise.isVoid()) {
        PlatformDependent.throwException(t);
    }

    return promise.setFailure(t);
  }

  return promise.setSuccess();
}
 
Example 2
Source File: MqttLoggerChannelHandler.java    From spring-boot-protocol with Apache License 2.0 5 votes vote down vote up
@Override
protected void onMessageWriter(ChannelHandlerContext ctx, MqttMessage msg, ChannelPromise promise) throws Exception {
    logMQTTMessage(ctx, msg, "C<-B");
    if(promise.isVoid()) {
        ctx.write(msg, promise);
    }else {
        ctx.write(msg, promise).addListener(ChannelFutureListener.CLOSE_ON_FAILURE);
    }
}
 
Example 3
Source File: IdleStateChecker.java    From Jupiter with Apache License 2.0 5 votes vote down vote up
@Override
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
    if (writerIdleTimeMillis > 0 || allIdleTimeMillis > 0) {
        if (promise.isVoid()) {
            firstWriterIdleEvent = firstAllIdleEvent = true;
            lastWriteTime = SystemClock.millisClock().now(); // make hb for firstWriterIdleEvent and firstAllIdleEvent
        } else {
            promise.addListener(writeListener);
        }
    }
    ctx.write(msg, promise);
}