Skip to content

DefaultDataBuffer fails to transform its content to a string #31873

Closed
@access-control-rtfm

Description

@access-control-rtfm

Affects: 6.*.*


The following test fails:

import static org.junit.jupiter.api.Assertions.*;

import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;

import org.junit.jupiter.api.Test;
import org.springframework.core.io.buffer.DataBuffer;
import org.springframework.core.io.buffer.DefaultDataBufferFactory;

class DefaultDataBufferStringTransformationTest {

    @Test
    void test() {
        Charset charset = StandardCharsets.UTF_8;
        DataBuffer dataBuffer = DefaultDataBufferFactory.sharedInstance.allocateBuffer(DefaultDataBufferFactory.DEFAULT_INITIAL_CAPACITY);
        String name = "Müller";
        int repeatCount = 19;
        for(int i = 0; i < repeatCount; i++) {
            dataBuffer.write(name, charset);
        }
        String expected = name.repeat(repeatCount);
        String result = dataBuffer.toString(charset);
        assertEquals(expected, result);
    }

}

May be it has something to do with this issue.

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)status: backportedAn issue that has been backported to maintenance branchestype: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions