From b272f4e6153afed10b6eb1dab939b2e142a7a96a Mon Sep 17 00:00:00 2001 From: Arjen Poutsma Date: Mon, 18 Dec 2023 11:43:18 +0100 Subject: [PATCH] Correctly set capacity of remainder in DefaultDataBuffer::split This commit ensures that the capacity of the remainder buffer after a split operation is set directly on the field. Calling capacity(int) caused a new buffer to be allocated. See gh-31848 Closes gh-31859 --- .../org/springframework/core/io/buffer/DefaultDataBuffer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-core/src/main/java/org/springframework/core/io/buffer/DefaultDataBuffer.java b/spring-core/src/main/java/org/springframework/core/io/buffer/DefaultDataBuffer.java index def3ccf39649..4456f975bd9e 100644 --- a/spring-core/src/main/java/org/springframework/core/io/buffer/DefaultDataBuffer.java +++ b/spring-core/src/main/java/org/springframework/core/io/buffer/DefaultDataBuffer.java @@ -371,7 +371,7 @@ public DataBuffer split(int index) { .slice(); this.writePosition = Math.max(this.writePosition, index) - index; this.readPosition = Math.max(this.readPosition, index) - index; - capacity(this.byteBuffer.capacity()); + this.capacity = this.byteBuffer.capacity(); return result; }