takeUntilByteCount actually uses takeUntil

Issue: SPR-17188
This commit is contained in:
Rossen Stoyanchev
2018-08-02 15:00:56 +03:00
parent 542ed81d5c
commit 5095ec40b5
2 changed files with 22 additions and 12 deletions

View File

@@ -396,14 +396,11 @@ public abstract class DataBufferUtils {
AtomicLong countDown = new AtomicLong(maxByteCount);
return Flux.from(publisher)
.takeWhile(buffer -> {
int delta = -buffer.readableByteCount();
return countDown.getAndAdd(delta) >= 0;
})
.map(buffer -> {
long count = countDown.get();
long count = countDown.addAndGet(-buffer.readableByteCount());
return count >= 0 ? buffer : buffer.slice(0, buffer.readableByteCount() + (int) count);
});
})
.takeUntil(buffer -> countDown.get() <= 0);
}
/**