Skip to content

Use of CompositeByteBuf in NettyDataBuffer results in IllegalReferenceCountException [SPR-16351] #20898

@spring-projects-issues

Description

@spring-projects-issues

Abhijit Sarkar opened SPR-16351 and commented

DataBuffer write(DataBuffer... buffers) is supposed to "Write one or more DataBuffers to this buffer, starting at the current writing position" but it doesn't.

Consider buffer = "abc", slice = "def" and buffer.writePosition() = 3. buffer.write(slice) is supposed to produce abcdef but instead buffer becomes abcabc. The workaround is to use the write overload that takes a byte[], like so:

DataBuffer slice = buffer.slice(startIdx, length);
byte[] slice1 = new byte[length];
slice.read(slice1, 0, slice1.length);
buffer.write(slice1);

Related to SO answer https://stackoverflow.com/a/48111196/839733


Affects: 5.0.2

Reference URL: https://stackoverflow.com/a/48111196/839733

Issue Links:

Referenced from: commits 69ccba3, 8a129ef, e6893da

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)in: webIssues in web modules (web, webmvc, webflux, websocket)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions