tyrus
  1. tyrus
  2. TYRUS-213

Session.close(CloseReason) should not throw IllegalStateException

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Invalid
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:

      Tyrus trunk (rev. 720)

      Description

      I don't see a reason why close(CloseReason) shouldn't be allowed on a closed Session while close() is perfectly legal.

      EE 7 Javadoc for Session says:

      Once the session is closed, it is no longer valid for use by applications. Calling any of its methods (with the exception of the close() methods) once the session has been closed will result in an IllegalStateException being thrown.

      "close() methods" is plural (and "the session" is singular), so I conclude it must mean both close methods on a single object, namely close() and close(CloseReason).

        Activity

        Hide
        Pavel Bucek added a comment -

        please use users@tyrus.java.net for questions, jira should serve only for bug reports/RFEs.

        Session#close() is implementation of Closeable#close():

            /**
             * Closes this stream and releases any system resources associated
             * with it. If the stream is already closed then invoking this
             * method has no effect.
             *
             * @throws IOException if an I/O error occurs
             */
            public void close() throws IOException;

        so this basically answers one of your questions.

        Session#close(CloseReason) throws ISE when closed, because it needs to signal that nothing has been sent over the wire, so the other side did not receive information contained in your CloseReason instance.

        And BTW, there is a project for WebSocket API related issues - http://java.net/projects/websocket-spec/. Tyrus is reference implementation and cannot "force" any JSR 356 API changes.

        Show
        Pavel Bucek added a comment - please use users@tyrus.java.net for questions, jira should serve only for bug reports/RFEs. Session#close() is implementation of Closeable#close(): /** * Closes this stream and releases any system resources associated * with it. If the stream is already closed then invoking this * method has no effect. * * @ throws IOException if an I/O error occurs */ public void close() throws IOException; so this basically answers one of your questions. Session#close(CloseReason) throws ISE when closed, because it needs to signal that nothing has been sent over the wire, so the other side did not receive information contained in your CloseReason instance. And BTW, there is a project for WebSocket API related issues - http://java.net/projects/websocket-spec/ . Tyrus is reference implementation and cannot "force" any JSR 356 API changes.

          People

          • Assignee:
            Pavel Bucek
            Reporter:
            kithouna
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: