Closes gh-30967

Motivation

// DefaultDataBuffer
    public ByteBuffer getNativeBuffer() {
        this.byteBuffer.position(this.readPosition);
        this.byteBuffer.limit(readableByteCount()); // 👈 limit should be writePosition, not readableByteCount
        return this.byteBuffer;
    }
  • We found that DefaultDataBuffer#getNativeBuffer set byteBuffer#limit as readableByteCount() incorrectly so fix to writePosition

Modification

  • Fix DefaultDataBuffer#getNativeBuffer() to set correct limit as writePosition instead of readableByteCount()

Result

  • Now DefaultDataBuffer#getNativeBuffer() return native bytebuffer with correct limit
  • Close #30967

Comment From: poutsma

Thanks for supplying a PR. I decided to change the fix by returning a duplicate with independent position and limit, instead changing these on the buffer itself. This is arguably the way it should have been since 5fc18064f26a2541cce0432a4cb0fc01104972e8.

Comment From: injae-kim

Oh thank you for your additional polishing :)

I'm so happy that this is my first contribution(https://github.com/spring-projects/spring-framework/commit/969d0bd08bab519311040649f1b12a70c944d7e1) on spring-framework! I'll continue to contribute by another PR 🚀