Uploaded image for project: 'Commons Digester'
  1. Commons Digester
  2. DIGESTER-57

Digester always logs exceptions

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • None
    • None
    • Operating System: All
      Platform: All

    • 4553

    Description

      If an exception is thrown by a rule during the parse, Digester will log a
      message containing the exception stack trace, even if debug==0. This is
      undesirable for two reasons:

      1. We might not want to log this, either because the application catches the
      exception and cleanly handles it (in which case, there's really no 'need to
      know'), or because the exception is part of the normal application flow (for
      example, a rule might throw an exception in order to prematurely terminate the
      parse.)

      2. By default, log() outputs to System.out. Applications that pipe output to
      System.out probably do not want stack traces going there.

      In my particular case, I have unit tests that intentionally send bad data
      through the digester, to validate that various Rule classes detect the bad data
      and throw the proper exceptions. It's distracting to see stack traces in the
      unit test report, for tests that did not fail.

      Workaround:
      Pass a dummy logging writer to the Digester via setWriter(), that outputs
      nothing if debug == 0.

      Suggestions:
      1. Change Digester to log exceptions only if debug > 0. Or create a debug level
      of -1 that logs nothing; this will fully preserve backward compatibility.
      2. Change the default log output stream from System.out to System.err

      Attachments

        Activity

          People

            Unassigned Unassigned
            dmartin@altoweb.com David H. Martin
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: