diff --git a/spring-core/src/main/java/org/springframework/core/io/buffer/NettyDataBuffer.java b/spring-core/src/main/java/org/springframework/core/io/buffer/NettyDataBuffer.java index b603b0d347f..dd5faf593bc 100644 --- a/spring-core/src/main/java/org/springframework/core/io/buffer/NettyDataBuffer.java +++ b/spring-core/src/main/java/org/springframework/core/io/buffer/NettyDataBuffer.java @@ -179,15 +179,18 @@ public class NettyDataBuffer implements PooledDataBuffer { if (buffers.length > 0) { if (hasNettyDataBuffers(buffers)) { - ByteBuf[] nativeBuffers = Arrays.stream(buffers) - .map(b -> ((NettyDataBuffer) b).getNativeBuffer()) - .toArray(ByteBuf[]::new); + ByteBuf[] nativeBuffers = new ByteBuf[buffers.length]; + for (int i = 0 ; i < buffers.length; i++) { + nativeBuffers[i] = ((NettyDataBuffer) buffers[i]).getNativeBuffer(); + } write(nativeBuffers); } else { - ByteBuffer[] byteBuffers = - Arrays.stream(buffers).map(DataBuffer::asByteBuffer) - .toArray(ByteBuffer[]::new); + ByteBuffer[] byteBuffers = new ByteBuffer[buffers.length]; + for (int i = 0 ; i < buffers.length; i++) { + byteBuffers[i] = buffers[i].asByteBuffer(); + + } write(byteBuffers); } } diff --git a/spring-core/src/main/java/org/springframework/core/io/buffer/NettyDataBufferFactory.java b/spring-core/src/main/java/org/springframework/core/io/buffer/NettyDataBufferFactory.java index c1236354446..f91be4eea93 100644 --- a/spring-core/src/main/java/org/springframework/core/io/buffer/NettyDataBufferFactory.java +++ b/spring-core/src/main/java/org/springframework/core/io/buffer/NettyDataBufferFactory.java @@ -82,6 +82,15 @@ public class NettyDataBufferFactory implements DataBufferFactory { return new NettyDataBuffer(byteBuf, this); } + /** + * Wrap the given Netty {@link ByteBuf} in a {@code NettyDataBuffer}. + * @param byteBuf the Netty byte buffer to wrap + * @return the wrapped buffer + */ + public NettyDataBuffer wrap(ByteBuf byteBuf) { + return new NettyDataBuffer(byteBuf, this); + } + /** * {@inheritDoc} *
This implementation uses Netty's {@link CompositeByteBuf}. @@ -97,15 +106,6 @@ public class NettyDataBufferFactory implements DataBufferFactory { return new NettyDataBuffer(composite, this); } - /** - * Wrap the given Netty {@link ByteBuf} in a {@code NettyDataBuffer}. - * @param byteBuf the Netty byte buffer to wrap - * @return the wrapped buffer - */ - public NettyDataBuffer wrap(ByteBuf byteBuf) { - return new NettyDataBuffer(byteBuf, this); - } - /** * Return the given Netty {@link DataBuffer} as a {@link ByteBuf}. Returns the * {@linkplain NettyDataBuffer#getNativeBuffer() native buffer} if {@code buffer} is diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/AbstractMessageReaderArgumentResolver.java b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/AbstractMessageReaderArgumentResolver.java index 916b56f04b8..9e676ad784c 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/AbstractMessageReaderArgumentResolver.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/AbstractMessageReaderArgumentResolver.java @@ -127,13 +127,13 @@ public abstract class AbstractMessageReaderArgumentResolver extends HandlerMetho /** * Read the body from a method argument with {@link HttpMessageReader}. - * @param bodyParam the {@link MethodParameter} to read - * @param actualParam the actual {@link MethodParameter} to read; could be different - * from {@code bodyParameter} when processing {@code HttpEntity} for example + * @param bodyParam represents the element type for the body + * @param actualParam the actual method argument type; possibly different + * from {@code bodyParam}, e.g. for an {@code HttpEntity} argument * @param isBodyRequired true if the body is required * @param bindingContext the binding context to use * @param exchange the current exchange - * @return the body + * @return a Mono with the value to use for the method argument * @since 5.0.2 */ protected Mono