Remove buffer release used as workaround

The extra buffer release was used as a workaround for a reactor core
issue and should have already been removed as part of
b3bc2d9253.
master
Rossen Stoyanchev 6 years ago
parent 3ebbfa2191
commit bd2c213b47
  1. 14
      spring-core/src/main/java/org/springframework/core/io/buffer/DataBufferUtils.java

@ -524,13 +524,9 @@ public abstract class DataBufferUtils {
long pos = this.position.addAndGet(read); long pos = this.position.addAndGet(read);
dataBuffer.writePosition(read); dataBuffer.writePosition(read);
this.sink.next(dataBuffer); this.sink.next(dataBuffer);
// It's possible for cancellation to happen right before the push into the sink // onNext may have led to onCancel (e.g. downstream takeUntil)
if (this.disposed.get()) { if (this.disposed.get()) {
// TODO: complete();
// This is not ideal since we already passed the buffer into the sink and
// releasing may cause something reading to fail. Maybe we won't have to
// do this after https://github.com/reactor/reactor-core/issues/1634
complete(dataBuffer);
} }
else { else {
DataBuffer newDataBuffer = this.dataBufferFactory.allocateBuffer(this.bufferSize); DataBuffer newDataBuffer = this.dataBufferFactory.allocateBuffer(this.bufferSize);
@ -539,12 +535,12 @@ public abstract class DataBufferUtils {
} }
} }
else { else {
complete(dataBuffer); release(dataBuffer);
complete();
} }
} }
private void complete(DataBuffer dataBuffer) { private void complete() {
release(dataBuffer);
this.sink.complete(); this.sink.complete();
closeChannel(this.channel); closeChannel(this.channel);
} }

Loading…
Cancel
Save