Exemple #1
0
    @Override
    public void channelInactive(ChannelHandlerContext ctx) throws Exception {
      super.channelInactive(ctx);

      if (failOnMissingResponse) {
        long missingResponses = requestResponseCounter.get();
        if (missingResponses > 0) {
          ctx.fireExceptionCaught(
              new PrematureChannelClosureException(
                  "channel gone inactive with " + missingResponses + " missing response(s)"));
        }
      }
    }
Exemple #2
0
 @Override
 protected void decode(ChannelHandlerContext ctx, ByteBuf buffer, MessageList<Object> out)
     throws Exception {
   if (done) {
     int readable = actualReadableBytes();
     if (readable == 0) {
       // if non is readable just return null
       // https://github.com/netty/netty/issues/1159
       return;
     }
     out.add(buffer.readBytes(readable));
   } else {
     int oldSize = out.size();
     super.decode(ctx, buffer, out);
     if (failOnMissingResponse) {
       int size = out.size();
       for (int i = oldSize; i < size; i++) {
         decrement(out.get(i));
       }
     }
   }
 }