code: protected long calculateSize(Object msg) {
          if (msg instanceof ByteBuf) {
              return ((ByteBuf) msg).readableBytes();
          }
          if (msg instanceof ByteBufHolder) {
              return ((ByteBufHolder) msg).content().readableBytes();
          }
          return -1;
      }
docs: Calculate the size of the given {@link Object}.
  
  This implementation supports {@link ByteBuf} and {@link ByteBufHolder}. Sub-classes may override this.
  @param msg the msg for which the size should be calculated.
  @return size the size of the msg or {@code -1} if unknown.