jsr340-experts@servlet-spec.java.net

[jsr340-experts] Re: Calls to setReadListener and setWriteListener

From: Rémy Maucherat <rmaucher_at_redhat.com>
Date: Mon, 10 Dec 2012 19:38:35 +0100

On 12/10/2012 07:37 PM, Rajiv Mordani wrote:
> All,
> For the non-blocking IO we have calls in the ServletInputStream
> and ServletOutputStream to set the read and write listeners
> respectively. Shing Wai and I were discussing what the behavior should
> be for multiple calls to these methods. For example if I have the
> following piece of code - what should the behavior be.
>
> public class MyServlet extends HttpServlet {
> public void doGet (HttpServletRequest req, HttpServletResponse res) {
> ServletInputStream sis = req.getInputStream();
> sis.setReadListener(listener1);
> ...
> sis.setReadListener(listener2);
> }
>
> }
>
> similarly for the WriteListener.
>
> In my opinion this should not be allowed and we should throw some
> RuntimeException - maybe an ISE or a UnsupportedOperationException.
> Thoughts?
This would look like a programming error. As for the exception type,
this sounds like it is caused by the state, so it looks more like an ISE
to me.

Rémy