jetty.project icon indicating copy to clipboard operation
jetty.project copied to clipboard

Throw warning if ServletInputStream.transferTo(OutputStream) is used while in Async ReadListener is in use?

Open joakime opened this issue 1 year ago • 1 comments

Jetty version(s) 12.0.8

Enhancement Description

If a Servlet is in an active ReadListener mode (Async Read), and there is code that attempts to use ServletInputStream.transferTo() style methods (that result in multiple read attempts) then it I think using that method should throw an IllegalStateException indicating that this method is unsupported during ReadListener operations.

joakime avatar Apr 18 '24 01:04 joakime

This is a topic opened up at the Servlet spec at https://github.com/jakartaee/servlet/issues/301

joakime avatar Apr 18 '24 01:04 joakime

We have now followed the behavior suggested in https://github.com/jakartaee/servlet/issues/301 from jetty 12 onwards. This means that all the methods like transferTo and skipN will ultimately call read, which if is in async mode will ultimately throw java.lang.IllegalStateException: read on unready input if it cannot progress.

gregw avatar Aug 28 '24 23:08 gregw