Skip to content

DataBuffer.write(CharSequence charSequence, Charset charset) fails on empty string with java.lang.IllegalStateException: Current state = RESET, new state = FLUSHED #22262

@oleg-alexeyev

Description

@oleg-alexeyev

Spring WebFlux 5.1.4
First reproduced on a controller returning an empty response, it's easy to reproduce using the following snippet:

    DataBuffer buffer = new DefaultDataBufferFactory().allocateBuffer();
    buffer.write("", StandardCharsets.UTF_8);

the following exception is thrown:

java.lang.IllegalStateException: Current state = RESET, new state = FLUSHED
	at java.nio.charset.CharsetEncoder.throwIllegalStateException(CharsetEncoder.java:992)
	at java.nio.charset.CharsetEncoder.flush(CharsetEncoder.java:675)
	at org.springframework.core.io.buffer.DataBuffer.write(DataBuffer.java:260)

Fortunately, netty stack is not affected as NettyDataBuffer has its own implementation.

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions