diff --git a/redisson/src/main/java/org/redisson/RedissonObject.java b/redisson/src/main/java/org/redisson/RedissonObject.java index 462e49516..dc2fe2433 100644 --- a/redisson/src/main/java/org/redisson/RedissonObject.java +++ b/redisson/src/main/java/org/redisson/RedissonObject.java @@ -483,6 +483,17 @@ public abstract class RedissonObject implements RObject { } } + protected final void encode(Collection params, Consumer> func) { + try { + func.accept(params); + } catch (Exception e) { + params.forEach(v -> { + ReferenceCountUtil.safeRelease(v); + }); + throw e; + } + } + protected final void encodeMapValues(Collection params, Collection values) { try { for (Object object : values) {