Recent, related efforts on this topic include
SPR-17025, SPR-17246, and SPR-16782, but those changes needs some refinement plus a comprehensive review of all DataBuffer handling code with an eye towards error and cancellation signal cases.
This is an umbrella ticket with sub-tasks:
SPR-17411DataBufferUtils. SPR-17410ReactorServerHttpRequest to drop the onDiscard hook. SPR-17410Reactive Streams bridge in spring-web (Servlet, Undertow, HTTP and WebSocket). SPR-17418Decoders and message readers. SPR-17419Encoders and message writers. SPR-17424Jetty ClientHttpConnector. SPR-17409Update docs for releasing data buffers on error/cancellation.
For 4) and 5) above, perhaps we should consider inserting a common onDiscard at the point of using codecs to ensure consistent behavior? Of course individual codecs still need to be able to do the right thing on their own, but perhaps a hint could be passed in to indicate when onDiscard is handled externally..