Merge pull request #6266 from lehuuthanh5/potential_memoryleak_tocachekey

Fix potential memory leak on method LocalCacheView.toCacheKey if useObjectAsCacheKey = true
pull/6272/head
Nikita Koksharov 3 months ago committed by GitHub
commit 7e3c59e673
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -144,6 +144,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