/** * Wrap the given {@link ByteBuf}s in an unmodifiable {@link ByteBuf}. Be aware the returned {@link ByteBuf} will * not try to slice the given {@link ByteBuf}s to reduce GC-Pressure. * * The returned {@link ByteBuf} may wrap the provided array directly, and so should not be subsequently modified. */ public static ByteBuf wrappedUnmodifiableBuffer(ByteBuf... buffers) { return wrappedUnmodifiableBuffer(false, buffers); }
/** * Wrap the given {@link ByteBuf}s in an unmodifiable {@link ByteBuf}. Be aware the returned {@link ByteBuf} will * not try to slice the given {@link ByteBuf}s to reduce GC-Pressure. * * The returned {@link ByteBuf} may wrap the provided array directly, and so should not be subsequently modified. */ public static ByteBuf wrappedUnmodifiableBuffer(ByteBuf... buffers) { return wrappedUnmodifiableBuffer(false, buffers); }
/** * Wrap the given {@link ByteBuf}s in an unmodifiable {@link ByteBuf}. Be aware the returned {@link ByteBuf} will * not try to slice the given {@link ByteBuf}s to reduce GC-Pressure. * * @deprecated Use {@link #wrappedUnmodifiableBuffer(ByteBuf...)}. */ @Deprecated public static ByteBuf unmodifiableBuffer(ByteBuf... buffers) { return wrappedUnmodifiableBuffer(true, buffers); }
/** * Wrap the given {@link ByteBuf}s in an unmodifiable {@link ByteBuf}. Be aware the returned {@link ByteBuf} will * not try to slice the given {@link ByteBuf}s to reduce GC-Pressure. * * The returned {@link ByteBuf} may wrap the provided array directly, and so should not be subsequently modified. */ public static ByteBuf wrappedUnmodifiableBuffer(ByteBuf... buffers) { return wrappedUnmodifiableBuffer(false, buffers); }
/** * Wrap the given {@link ByteBuf}s in an unmodifiable {@link ByteBuf}. Be aware the returned {@link ByteBuf} will * not try to slice the given {@link ByteBuf}s to reduce GC-Pressure. * * @deprecated Use {@link #wrappedUnmodifiableBuffer(ByteBuf...)}. */ @Deprecated public static ByteBuf unmodifiableBuffer(ByteBuf... buffers) { return wrappedUnmodifiableBuffer(true, buffers); }
/** * Wrap the given {@link ByteBuf}s in an unmodifiable {@link ByteBuf}. Be aware the returned {@link ByteBuf} will * not try to slice the given {@link ByteBuf}s to reduce GC-Pressure. * * @deprecated Use {@link #wrappedUnmodifiableBuffer(ByteBuf...)}. */ @Deprecated public static ByteBuf unmodifiableBuffer(ByteBuf... buffers) { return wrappedUnmodifiableBuffer(true, buffers); }
/** * Wrap the given {@link ByteBuf}s in an unmodifiable {@link ByteBuf}. Be aware the returned {@link ByteBuf} will * not try to slice the given {@link ByteBuf}s to reduce GC-Pressure. * * The returned {@link ByteBuf} may wrap the provided array directly, and so should not be subsequently modified. */ public static ByteBuf wrappedUnmodifiableBuffer(ByteBuf... buffers) { return wrappedUnmodifiableBuffer(false, buffers); }
/** * Wrap the given {@link ByteBuf}s in an unmodifiable {@link ByteBuf}. Be aware the returned {@link ByteBuf} will * not try to slice the given {@link ByteBuf}s to reduce GC-Pressure. * * @deprecated Use {@link #wrappedUnmodifiableBuffer(ByteBuf...)}. */ @Deprecated public static ByteBuf unmodifiableBuffer(ByteBuf... buffers) { return wrappedUnmodifiableBuffer(true, buffers); }
/** * Wrap the given {@link ByteBuf}s in an unmodifiable {@link ByteBuf}. Be aware the returned {@link ByteBuf} will * not try to slice the given {@link ByteBuf}s to reduce GC-Pressure. * * The returned {@link ByteBuf} may wrap the provided array directly, and so should not be subsequently modified. */ public static ByteBuf wrappedUnmodifiableBuffer(ByteBuf... buffers) { return wrappedUnmodifiableBuffer(false, buffers); }
/** * Wrap the given {@link ByteBuf}s in an unmodifiable {@link ByteBuf}. Be aware the returned {@link ByteBuf} will * not try to slice the given {@link ByteBuf}s to reduce GC-Pressure. * * @deprecated Use {@link #wrappedUnmodifiableBuffer(ByteBuf...)}. */ @Deprecated public static ByteBuf unmodifiableBuffer(ByteBuf... buffers) { return wrappedUnmodifiableBuffer(true, buffers); }
private ByteBuf composeReceived() { if (received.isEmpty()) { return Unpooled.EMPTY_BUFFER; } else if (received.size() == 1) { return new ByteBufRef(received.remove(0)); } else { ByteBuf[] byteBufsArray = this.received.toArray(new ByteBuf[0]); received.clear(); return Unpooled.wrappedUnmodifiableBuffer(byteBufsArray); } }
@Override @NotNull ByteBuf encode( final @NotNull MqttStatefulPublish message, final @NotNull ByteBufAllocator allocator, final int encodedLength, final int remainingLength, final int propertyLength, final int omittedProperties) { final ByteBuffer payload = message.stateless().getRawPayload(); if ((payload != null) && payload.isDirect()) { final int encodedLengthWithoutPayload = encodedLength - payload.remaining(); final ByteBuf out = allocator.ioBuffer(encodedLengthWithoutPayload, encodedLengthWithoutPayload); encode(message, out, remainingLength, propertyLength, omittedProperties); return Unpooled.wrappedUnmodifiableBuffer(out, Unpooled.wrappedBuffer(payload)); } final ByteBuf out = allocator.ioBuffer(encodedLength, encodedLength); encode(message, out, remainingLength, propertyLength, omittedProperties); return out; }
@NotNull @Override ByteBuf encode( @NotNull final MqttStatefulPublish message, @NotNull final ByteBufAllocator allocator, final int encodedLength, final int remainingLength) { final ByteBuffer payload = message.stateless().getRawPayload(); if ((payload != null) && payload.isDirect()) { final int encodedLengthWithoutPayload = encodedLength - payload.remaining(); final ByteBuf out = allocator.ioBuffer(encodedLengthWithoutPayload, encodedLengthWithoutPayload); encode(message, out, remainingLength); return Unpooled.wrappedUnmodifiableBuffer(out, Unpooled.wrappedBuffer(payload)); } final ByteBuf out = allocator.ioBuffer(encodedLength, encodedLength); encode(message, out, remainingLength); return out; }