From 3ca22ad1808436e4a2508055073554662dd425ef Mon Sep 17 00:00:00 2001 From: Graham Date: Wed, 23 Sep 2020 20:16:43 +0100 Subject: [PATCH] Make Container extend DefaultByteBufHolder Implementing ReferenceCounted with delegation doesn't quite work, as the methods returning ReferenceCounted are not overriden to return Container. This can cause code inside Netty to unintentionally unwrap the Container. Signed-off-by: Graham --- .../main/java/dev/openrs2/archive/cache/CacheImporter.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/archive/src/main/java/dev/openrs2/archive/cache/CacheImporter.kt b/archive/src/main/java/dev/openrs2/archive/cache/CacheImporter.kt index 9acbb9cc..5b2ccf9c 100644 --- a/archive/src/main/java/dev/openrs2/archive/cache/CacheImporter.kt +++ b/archive/src/main/java/dev/openrs2/archive/cache/CacheImporter.kt @@ -12,7 +12,7 @@ import dev.openrs2.db.Database import io.netty.buffer.ByteBuf import io.netty.buffer.ByteBufAllocator import io.netty.buffer.ByteBufUtil -import io.netty.util.ReferenceCounted +import io.netty.buffer.DefaultByteBufHolder import java.io.IOException import java.sql.Connection import java.sql.Types @@ -25,8 +25,8 @@ public class CacheImporter @Inject constructor( private val alloc: ByteBufAllocator ) { private abstract class Container( - private val data: ByteBuf - ) : ReferenceCounted by data { + data: ByteBuf + ) : DefaultByteBufHolder(data) { val bytes: ByteArray = ByteBufUtil.getBytes(data, data.readerIndex(), data.readableBytes(), false) val crc32 = data.crc32() val whirlpool = Whirlpool.whirlpool(bytes)