Allow nullable ReferenceCounted objects to be passed to use

Signed-off-by: Graham <gpe@openrs2.org>
pull/132/head
Graham 3 years ago
parent 3289af5ddf
commit c295ecb0a0
  1. 4
      buffer/src/main/kotlin/org/openrs2/buffer/ReferenceCountedExtensions.kt

@ -2,10 +2,10 @@ package org.openrs2.buffer
import io.netty.util.ReferenceCounted import io.netty.util.ReferenceCounted
public inline fun <T : ReferenceCounted, R> T.use(block: (T) -> R): R { public inline fun <T : ReferenceCounted?, R> T.use(block: (T) -> R): R {
try { try {
return block(this) return block(this)
} finally { } finally {
release() this?.release()
} }
} }

Loading…
Cancel
Save