jsr340-experts@servlet-spec.java.net

[jsr340-experts] Calls to setReadListener and setWriteListener

From: Rajiv Mordani <rajiv.mordani_at_oracle.com>
Date: Mon, 10 Dec 2012 10:37:54 -0800

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?

- Rajiv