diff --git a/spring-messaging/src/main/java/org/springframework/messaging/rsocket/DefaultRSocketRequester.java b/spring-messaging/src/main/java/org/springframework/messaging/rsocket/DefaultRSocketRequester.java index d611f601bb..03dce9b453 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/rsocket/DefaultRSocketRequester.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/rsocket/DefaultRSocketRequester.java @@ -235,7 +235,7 @@ final class DefaultRSocketRequester implements RSocketRequester { DataBufferUtils.release(data); throw ex; } - return PayloadUtils.createPayload(metadata, data); + return PayloadUtils.createPayload(data, metadata); } private Mono emptyPayload() { diff --git a/spring-messaging/src/main/java/org/springframework/messaging/rsocket/DefaultRSocketRequesterBuilder.java b/spring-messaging/src/main/java/org/springframework/messaging/rsocket/DefaultRSocketRequesterBuilder.java index c73986b54d..84029fccdd 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/rsocket/DefaultRSocketRequesterBuilder.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/rsocket/DefaultRSocketRequesterBuilder.java @@ -202,7 +202,7 @@ final class DefaultRSocketRequesterBuilder implements RSocketRequester.Builder { } metadata = metadata != null ? metadata : emptyBuffer(strategies); data = data != null ? data : emptyBuffer(strategies); - return PayloadUtils.createPayload(metadata, data); + return PayloadUtils.createPayload(data, metadata); } private DataBuffer emptyBuffer(RSocketStrategies strategies) { diff --git a/spring-messaging/src/main/java/org/springframework/messaging/rsocket/PayloadUtils.java b/spring-messaging/src/main/java/org/springframework/messaging/rsocket/PayloadUtils.java index 43135504d8..7b2e2a7f91 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/rsocket/PayloadUtils.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/rsocket/PayloadUtils.java @@ -72,11 +72,11 @@ public abstract class PayloadUtils { * or using {@link Unpooled#wrappedBuffer(ByteBuffer...)} if necessary. * Otherwise, if both are {@link DefaultDataBuffer}, then * {@link DefaultPayload} is created. - * @param metadata the metadata part for the payload * @param data the data part for the payload + * @param metadata the metadata part for the payload * @return the created payload */ - public static Payload createPayload(DataBuffer metadata, DataBuffer data) { + public static Payload createPayload(DataBuffer data, DataBuffer metadata) { return data instanceof NettyDataBuffer || metadata instanceof NettyDataBuffer ? ByteBufPayload.create(asByteBuf(data), asByteBuf(metadata)) : DefaultPayload.create(asByteBuffer(data), asByteBuffer(metadata)); diff --git a/spring-messaging/src/test/java/org/springframework/messaging/rsocket/DefaultMetadataExtractorTests.java b/spring-messaging/src/test/java/org/springframework/messaging/rsocket/DefaultMetadataExtractorTests.java index 1e64d3e18a..5dc24409d6 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/rsocket/DefaultMetadataExtractorTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/rsocket/DefaultMetadataExtractorTests.java @@ -163,7 +163,7 @@ public class DefaultMetadataExtractorTests { private Payload createPayload(DataBuffer metadata) { - return PayloadUtils.createPayload(metadata, this.strategies.dataBufferFactory().allocateBuffer()); + return PayloadUtils.createPayload(this.strategies.dataBufferFactory().allocateBuffer(), metadata); } } diff --git a/spring-messaging/src/test/java/org/springframework/messaging/rsocket/PayloadUtilsTests.java b/spring-messaging/src/test/java/org/springframework/messaging/rsocket/PayloadUtilsTests.java index 9e11a5485a..0377ac4fdf 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/rsocket/PayloadUtilsTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/rsocket/PayloadUtilsTests.java @@ -81,7 +81,7 @@ public class PayloadUtilsTests { NettyDataBuffer data = createNettyDataBuffer("sample data"); NettyDataBuffer metadata = createNettyDataBuffer("sample metadata"); - Payload payload = PayloadUtils.createPayload(metadata, data); + Payload payload = PayloadUtils.createPayload(data, metadata); try { assertThat(payload).isInstanceOf(ByteBufPayload.class); assertThat(payload.data()).isSameAs(data.getNativeBuffer()); @@ -96,7 +96,7 @@ public class PayloadUtilsTests { public void createWithDefaultBuffers() { DataBuffer data = createDefaultDataBuffer("sample data"); DataBuffer metadata = createDefaultDataBuffer("sample metadata"); - Payload payload = PayloadUtils.createPayload(metadata, data); + Payload payload = PayloadUtils.createPayload(data, metadata); assertThat(payload).isInstanceOf(DefaultPayload.class); assertThat(payload.getDataUtf8()).isEqualTo(dataBufferToString(data)); @@ -107,7 +107,7 @@ public class PayloadUtilsTests { public void createWithNettyAndDefaultBuffers() { NettyDataBuffer data = createNettyDataBuffer("sample data"); DefaultDataBuffer metadata = createDefaultDataBuffer("sample metadata"); - Payload payload = PayloadUtils.createPayload(metadata, data); + Payload payload = PayloadUtils.createPayload(data, metadata); try { assertThat(payload).isInstanceOf(ByteBufPayload.class); assertThat(payload.data()).isSameAs(data.getNativeBuffer()); @@ -122,7 +122,7 @@ public class PayloadUtilsTests { public void createWithDefaultAndNettyBuffers() { DefaultDataBuffer data = createDefaultDataBuffer("sample data"); NettyDataBuffer metadata = createNettyDataBuffer("sample metadata"); - Payload payload = PayloadUtils.createPayload(metadata, data); + Payload payload = PayloadUtils.createPayload(data, metadata); try { assertThat(payload).isInstanceOf(ByteBufPayload.class); assertThat(payload.getDataUtf8()).isEqualTo(dataBufferToString(data));