glassfish
  1. glassfish
  2. GLASSFISH-20481

GlassFish does not log exceptions thrown by WebSocket callback methods

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 4.0_b87_RC3
    • Fix Version/s: 4.1
    • Component/s: web_socket
    • Labels:
      None

      Description

      If a webSocket @OnMessage callback throws a RuntimeException this is ignored by the container and nothing is logged in the server log to indicate that anything went wrong. This can lead to important failures being completely missed.

      Here's an example of a webSocket @OnMessage callback that throws a {{RuntimeException}:

          @OnMessage
          public void onMessage(final String message, final Session client) {
              Logger.getLogger(SampleWebSocket.class.getName()).log(Level.INFO, "SampleWebSocket.onMessage called");
              throw new RuntimeException("Ooh la la");
          }
      

      I think this is a bug in GlassFish. If a RuntimeException exception is thrown by a EJB business method then GlassFish logs it (with a stack trace) in the server log. However if a RuntimeException exception is thrown in a WebSocket callback then nothing is logged.

        Issue Links

          Activity

          Hide
          jitu added a comment -

          I agree with Nigel. I also observed the same behaviour (though Tyrus passes the exception to @OnError method correctly). If Tyrus is logging with lower level, then it should log with WARNING level.

          Show
          jitu added a comment - I agree with Nigel. I also observed the same behaviour (though Tyrus passes the exception to @OnError method correctly). If Tyrus is logging with lower level, then it should log with WARNING level.
          Hide
          stepan.kopriva added a comment -

          I have tried the provided sample with both glassfish-4.0-b89 (http://dlc.sun.com.edgesuite.net/glassfish/4.0/nightly/glassfish-4.0-b89-05_15_2013.zip) and latest glassfish from trunk. In both cases the result is the same - the exception gets logged with level SEVERE. So the level is not correct, however the exception gets logged.

          I agree with Jitu that the level should be WARNING. If you agree and won't provide any other proposal, I will change the log level to WARNING next week.

          Show
          stepan.kopriva added a comment - I have tried the provided sample with both glassfish-4.0-b89 ( http://dlc.sun.com.edgesuite.net/glassfish/4.0/nightly/glassfish-4.0-b89-05_15_2013.zip ) and latest glassfish from trunk. In both cases the result is the same - the exception gets logged with level SEVERE. So the level is not correct, however the exception gets logged. I agree with Jitu that the level should be WARNING. If you agree and won't provide any other proposal, I will change the log level to WARNING next week.
          Hide
          Nigel Deakin added a comment -

          I repeated my test case using the above @OnMessage callback with the released GlassFish Server Open Source Edition 4.0 (build 89) and am still not seeing any exception or error message logged in the server log when the @OnMessage callback throws an exception. I am using the default logging settings.

          Show
          Nigel Deakin added a comment - I repeated my test case using the above @OnMessage callback with the released GlassFish Server Open Source Edition 4.0 (build 89) and am still not seeing any exception or error message logged in the server log when the @OnMessage callback throws an exception. I am using the default logging settings.
          Hide
          stepan.kopriva added a comment -

          Fixed. If an Exception is thrown in the Endpoint which does not have @OnError method, the Exception is logged on INFO level.

          Show
          stepan.kopriva added a comment - Fixed. If an Exception is thrown in the Endpoint which does not have @OnError method, the Exception is logged on INFO level.

            People

            • Assignee:
              stepan.kopriva
              Reporter:
              Nigel Deakin
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: