Browse Source

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]
pull/2908/head
Ignacio Lozano 2 years ago committed by GitHub
parent
commit
162863020d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      spring-cloud-gateway-server/src/main/java/org/springframework/cloud/gateway/filter/factory/cache/ResponseCacheManager.java

2
spring-cloud-gateway-server/src/main/java/org/springframework/cloud/gateway/filter/factory/cache/ResponseCacheManager.java vendored

@ -98,7 +98,7 @@ public class ResponseCacheManager { @@ -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);

Loading…
Cancel
Save