-
Notifications
You must be signed in to change notification settings - Fork 586
Closed
Description
Describe the bug
With amqp-client java library version 5.27.0 the method writeToByteBuf in class com.rabbitmq.client.impl.Frame has a bug when writing the accumulator bytes in line 218
@Override
public void write(byte[] b) {
buf.writeBytes(buf);
}
buf.writeBytes(buf);
should be changed to
buf.writeBytes(b);
The effect is that an invalid frame will be sent to the RabbitMQ server, example for channel open:
01 00 01 00 00 00 05 ce
instead of
01 00 01 00 00 00 05 00 14 00 0a 00 ce
and no channels can be opened anymore.
Note for reproduction:
java.io.ByteArrayOutputStream.writeTo(OutputStream) calls either method
write(byte[] b)
or method
write(byte[] b, int off, int len)
depending the current thread is virtual or not
public void writeTo(OutputStream out) throws IOException {
if (Thread.currentThread().isVirtual()) {
byte[] bytes;
synchronized (this) {
bytes = Arrays.copyOf(buf, count);
}
out.write(bytes);
} else synchronized (this) {
out.write(buf, 0, count);
}
}
Reproduction steps
- open a RabbitMQ connection with netty config and virtual thread
- create a channel
Expected behavior
Channel should be created, accumulator bytes should be sent to RabbitMQ
Additional context
No response