Ensure proper buffer caching

This commit is contained in:
themode 2022-01-01 20:52:01 +01:00 committed by TheMode
parent e169b631d5
commit 75b54e6302

View File

@ -35,8 +35,11 @@ public class SendablePacketTest {
assertSame(packet, cached.packet());
var buffer = PacketUtils.allocateTrimmedPacket(packet);
assertEquals(buffer.body(), cached.body());
assertEquals(buffer.body(), cached.body());
var cachedBuffer = cached.body();
assertEquals(buffer.body(), cachedBuffer);
// May fail in the very unlikely case where soft references are cleared
// Rare enough to make this test worth it
assertSame(cached.body(), cachedBuffer);
assertSame(packet, cached.packet());
}