Fix potential memory leak on method LocalCacheView.toCacheKey if useObjectAsCacheKey = true

Signed-off-by: Le Thanh <huuthanh.qt.spkt@gmail.com>
pull/6266/head
Le Thanh 3 months ago
parent 35a5dec511
commit 46ed4fd7fe

@ -150,6 +150,7 @@ public class RedissonLocalCachedMap<K, V> extends RedissonMap<K, V> implements R
}
listener.notifyInvalidate(new CacheValue(key, oldV));
listener.notifyUpdate(newValue);
localCacheView.putCacheKey(key, cacheKey);
return oldValue;
}

@ -281,16 +281,18 @@ public class LocalCacheView<K, V> {
}
ByteBuf encoded = object.encodeMapKey(key);
try {
cacheKey = toCacheKey(encoded);
if (useObjectAsCacheKey) {
cacheKeyMap.put(key, cacheKey);
}
return cacheKey;
return toCacheKey(encoded);
} finally {
encoded.release();
}
}
public void putCacheKey(Object key, CacheKey cacheKey) {
if (useObjectAsCacheKey) {
cacheKeyMap.put(key, cacheKey);
}
}
public CacheKey toCacheKey(ByteBuf encodedKey) {
return new CacheKey(Hash.hash128toArray(encodedKey));
}

Loading…
Cancel
Save