Uploaded image for project: 'RESTEasy'
  1. RESTEasy
  2. RESTEASY-105

Do not print exception stacktraces

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Critical Critical
    • Beta 6
    • Beta 5
    • jaxrs
    • None

      The Resteasy code logs/prints exceptions and stacktraces, e.g. MethodInjectorImpl:

      if (wae.getResponse() != null)

      { cause.printStackTrace(); return wae.getResponse(); }

      ResourceMethod.java:

      try

      { index.populateUriInfoTemplateParams(request); jaxrsResponse = methodInjector.invoke(request, response, target); }

      catch (Failure e)

      { response.sendError(HttpServletResponse.SC_BAD_REQUEST); e.printStackTrace(); return; }

      This kind of code makes Resteasy a burden in production because some outer frame of the call stack might handle the response gracefully yet you end up with a log filled with nonsense exceptions. Debugging real issues is then incredibly difficult.

      Do not log and return. Assume that the caller can handle whatever you return and that the caller doesn't want or need your log.

      If you absolutely have to log something because you are sure that callers can't handle your return/throw, always use a proper logging solution that allows users to disable that log call. And do not use log.error() if you re-throw, use WARN or INFO.

            patriot1burke@gmail.com Bill Burke (Inactive)
            christian.bauer_jira Christian Bauer (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: