The CompositeBuffer.compose methods must return CompositeBuffer instead of Buffer

This commit is contained in:
Chris Vest 2021-04-28 12:27:03 +02:00
parent f2033263dd
commit e1cc445d11

View File

@ -147,7 +147,7 @@ public final class CompositeBuffer extends RcSupport<Buffer, CompositeBuffer> im
* @throws IllegalArgumentException if the given buffers have an inconsistent * @throws IllegalArgumentException if the given buffers have an inconsistent
* {@linkplain Buffer#order() byte order}. * {@linkplain Buffer#order() byte order}.
*/ */
public static Buffer compose(BufferAllocator allocator, Buffer... bufs) { public static CompositeBuffer compose(BufferAllocator allocator, Buffer... bufs) {
Stream<Buffer> bufferStream = Arrays.stream(bufs) Stream<Buffer> bufferStream = Arrays.stream(bufs)
.map(buf -> buf.acquire()); // Increments reference counts. .map(buf -> buf.acquire()); // Increments reference counts.
return new CompositeBuffer(allocator, filterExternalBufs(bufferStream), COMPOSITE_DROP, false); return new CompositeBuffer(allocator, filterExternalBufs(bufferStream), COMPOSITE_DROP, false);
@ -181,7 +181,7 @@ public final class CompositeBuffer extends RcSupport<Buffer, CompositeBuffer> im
* will be closed and descarded, respectively. * will be closed and descarded, respectively.
*/ */
@SafeVarargs @SafeVarargs
public static Buffer compose(BufferAllocator allocator, Send<Buffer>... sends) { public static CompositeBuffer compose(BufferAllocator allocator, Send<Buffer>... sends) {
Buffer[] bufs = new Buffer[sends.length]; Buffer[] bufs = new Buffer[sends.length];
IllegalStateException ise = null; IllegalStateException ise = null;
for (int i = 0; i < sends.length; i++) { for (int i = 0; i < sends.length; i++) {
@ -212,7 +212,7 @@ public final class CompositeBuffer extends RcSupport<Buffer, CompositeBuffer> im
* {@link #ensureWritable(int)} calls. * {@link #ensureWritable(int)} calls.
* @return A composite buffer that has no components, and has a capacity of zero. * @return A composite buffer that has no components, and has a capacity of zero.
*/ */
public static Buffer compose(BufferAllocator allocator) { public static CompositeBuffer compose(BufferAllocator allocator) {
return new CompositeBuffer(allocator, EMPTY_BUFFER_ARRAY, COMPOSITE_DROP, false); return new CompositeBuffer(allocator, EMPTY_BUFFER_ARRAY, COMPOSITE_DROP, false);
} }