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 <gpe@openrs2.dev>
bzip2
Graham 4 years ago
parent 9770bab86d
commit 3ca22ad180
  1. 6
      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)

Loading…
Cancel
Save