Browse Source

Replace explicit use of PooledDataBuffer.release()

pull/25351/head
Rossen Stoyanchev 5 years ago
parent
commit
3aaff40e2e
  1. 2
      spring-core/src/main/java/org/springframework/core/io/buffer/DataBufferUtils.java
  2. 3
      spring-web/src/main/java/org/springframework/http/codec/multipart/PartHttpMessageWriter.java

2
spring-core/src/main/java/org/springframework/core/io/buffer/DataBufferUtils.java

@ -504,7 +504,7 @@ public abstract class DataBufferUtils { @@ -504,7 +504,7 @@ public abstract class DataBufferUtils {
catch (IllegalStateException ex) {
// Avoid dependency on Netty: IllegalReferenceCountException
if (logger.isDebugEnabled()) {
logger.debug("Failed to release PooledDataBuffer", ex);
logger.debug("Failed to release PooledDataBuffer: " + dataBuffer, ex);
}
return false;
}

3
spring-web/src/main/java/org/springframework/http/codec/multipart/PartHttpMessageWriter.java

@ -26,6 +26,7 @@ import org.springframework.core.ResolvableType; @@ -26,6 +26,7 @@ import org.springframework.core.ResolvableType;
import org.springframework.core.codec.Hints;
import org.springframework.core.io.buffer.DataBuffer;
import org.springframework.core.io.buffer.DataBufferFactory;
import org.springframework.core.io.buffer.DataBufferUtils;
import org.springframework.core.io.buffer.PooledDataBuffer;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
@ -66,7 +67,7 @@ public class PartHttpMessageWriter extends MultipartWriterSupport implements Htt @@ -66,7 +67,7 @@ public class PartHttpMessageWriter extends MultipartWriterSupport implements Htt
Flux<DataBuffer> body = Flux.from(parts)
.concatMap(part -> encodePart(boundary, part, outputMessage.bufferFactory()))
.concatWith(generateLastLine(boundary, outputMessage.bufferFactory()))
.doOnDiscard(PooledDataBuffer.class, PooledDataBuffer::release);
.doOnDiscard(PooledDataBuffer.class, DataBufferUtils::release);
return outputMessage.writeWith(body);
}

Loading…
Cancel
Save