Uploaded image for project: 'Commons DBCP'
  1. Commons DBCP
  2. DBCP-305

Use API-specific exception for logging abandoned objects

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Trivial
    • Resolution: Fixed
    • None
    • 1.3
    • None

    Description

      When a DBCP-managed object (Connection, Statement, etc.) is considered "abandoned", a stack trace is emitted to stdout. Unfortunately, the stack trace is for a simple java.lang.Exception (created in AbandonedTrace.init and AbandonedTrace.setStackTrace) with no message.

      When scanning log files for exceptions, say, like this:

      grep "Exception" my_logfile.log, I simply shows:

      java.lang.Exception
      java.lang.Exception
      java.lang.Exception
      ...

      It would be nice to use a more descriptive exception (for instance, AbandonedObjectException) and/or add a descriptive message to the exception upon creation.

      For example, it would be useful to execute the above command and see:

      org.apache.commons.dbcp.AbandonedObjectException: DBCP object created 2009-11-05 10:15:00 by the following code was never closed

      Having the timestamp and a definite identification of the exception (i.e. the class name) on the same line of log output is preferable IMO.

      Implementation should be trivial; I'd be happy to submit a patch. Also, the format of the logging information isn't part of the API itself, so it shouldn't be a big deal to change it.

      Attachments

        1. DBCP-305.diff
          3 kB
          Christopher Schultz

        Activity

          People

            markt Mark Thomas
            chris@christopherschultz.net Christopher Schultz
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: