Remove duplicated DataBuffer that caused leak alert by LocalResponseCache (#2886)

Having `response.bufferFactory().wrap(byteBuffer)` left the original DataBuffer without calling internally the `release()` method, which also decrease the counter of the incoming references to the object by Netty memory leak control.

This copy is not necessary and it was making Netty losing the object, causing memory Leak alert

[connected #2879]
This commit is contained in:
Ignacio Lozano
2023-03-27 18:04:16 +02:00
committed by GitHub
parent 8abdf4be00
commit 162863020d

View File

@@ -98,7 +98,7 @@ public class ResponseCacheManager {
return body.map(dataBuffer -> {
ByteBuffer byteBuffer = dataBuffer.toByteBuffer().asReadOnlyBuffer();
cachedResponseBuilder.appendToBody(byteBuffer);
return response.bufferFactory().wrap(byteBuffer);
return dataBuffer;
}).doOnComplete(() -> {
CachedResponse responseToCache = cachedResponseBuilder.timestamp(toProcess.timestamp()).build();
saveMetadataInCache(metadataKey, metadata);