You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Christopher Schultz (JIRA)" <ji...@apache.org> on 2009/11/16 21:36:39 UTC
[jira] Created: (DBCP-305) Use API-specific exception for logging
abandoned objects
Use API-specific exception for logging abandoned objects
--------------------------------------------------------
Key: DBCP-305
URL: https://issues.apache.org/jira/browse/DBCP-305
Project: Commons Dbcp
Issue Type: Improvement
Reporter: Christopher Schultz
Priority: Trivial
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.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (DBCP-305) Use API-specific exception for logging
abandoned objects
Posted by "Mark Thomas (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/DBCP-305?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12779108#action_12779108 ]
Mark Thomas commented on DBCP-305:
----------------------------------
AbandonedTrace is the way to go. The deprecation markers should all be removed in trunk. Let me know if I missed one/some and I'll remove it/them.
> Use API-specific exception for logging abandoned objects
> --------------------------------------------------------
>
> Key: DBCP-305
> URL: https://issues.apache.org/jira/browse/DBCP-305
> Project: Commons Dbcp
> Issue Type: Improvement
> Reporter: Christopher Schultz
> Priority: Trivial
>
> 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.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Resolved: (DBCP-305) Use API-specific exception for logging
abandoned objects
Posted by "Mark Thomas (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/DBCP-305?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Mark Thomas resolved DBCP-305.
------------------------------
Resolution: Fixed
Thanks for the patch. It has been applied and will be in 1.3 onwards. I modified the patch slightly to use the same { location as the rest of the class and to make access to the SimpleDateFormat thread safe.
> Use API-specific exception for logging abandoned objects
> --------------------------------------------------------
>
> Key: DBCP-305
> URL: https://issues.apache.org/jira/browse/DBCP-305
> Project: Commons Dbcp
> Issue Type: Improvement
> Reporter: Christopher Schultz
> Assignee: Mark Thomas
> Priority: Trivial
> Fix For: 1.3
>
> Attachments: DBCP-305.diff
>
>
> 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.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (DBCP-305) Use API-specific exception for logging
abandoned objects
Posted by "Phil Steitz (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/DBCP-305?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12778683#action_12778683 ]
Phil Steitz commented on DBCP-305:
----------------------------------
Looks like a good idea. Patches welcome!
> Use API-specific exception for logging abandoned objects
> --------------------------------------------------------
>
> Key: DBCP-305
> URL: https://issues.apache.org/jira/browse/DBCP-305
> Project: Commons Dbcp
> Issue Type: Improvement
> Reporter: Christopher Schultz
> Priority: Trivial
>
> 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.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Closed: (DBCP-305) Use API-specific exception for logging
abandoned objects
Posted by "Phil Steitz (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/DBCP-305?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Phil Steitz closed DBCP-305.
----------------------------
> Use API-specific exception for logging abandoned objects
> --------------------------------------------------------
>
> Key: DBCP-305
> URL: https://issues.apache.org/jira/browse/DBCP-305
> Project: Commons Dbcp
> Issue Type: Improvement
> Reporter: Christopher Schultz
> Assignee: Mark Thomas
> Priority: Trivial
> Fix For: 1.3
>
> Attachments: DBCP-305.diff
>
>
> 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.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (DBCP-305) Use API-specific exception for logging
abandoned objects
Posted by "Christopher Schultz (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/DBCP-305?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12780022#action_12780022 ]
Christopher Schultz commented on DBCP-305:
------------------------------------------
Thanks for accepting this patch. I'm sorry I wasn't sensitive to the brace convention already in the file. I probably could have javadoc'd the inner class, too :)
I didn't think about the lack of thread safety of the SimpleDateFormat class: good catch. So this counts as a bugfix by markt (format was being used in an unsynchronized way prior to this patch) as well as an enhancement by me :)
If DBCP typically uses localized error messages, I'd be happy to provide another patch that localizes the exception's message.
> Use API-specific exception for logging abandoned objects
> --------------------------------------------------------
>
> Key: DBCP-305
> URL: https://issues.apache.org/jira/browse/DBCP-305
> Project: Commons Dbcp
> Issue Type: Improvement
> Reporter: Christopher Schultz
> Assignee: Mark Thomas
> Priority: Trivial
> Fix For: 1.3
>
> Attachments: DBCP-305.diff
>
>
> 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.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (DBCP-305) Use API-specific exception for logging
abandoned objects
Posted by "Christopher Schultz (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/DBCP-305?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12779106#action_12779106 ]
Christopher Schultz commented on DBCP-305:
------------------------------------------
I'm happy to provide a patch to AbandonedTrace, but it is marked as deprecated in the javadoc and I want to make sure I'm doing the right thing. There's an svn comment from markt stating that the "problem" has been fixed and so AbandonedTrace need not be deprecated, so I guess that means AbandonedTrace is still the way to do, eh?
> Use API-specific exception for logging abandoned objects
> --------------------------------------------------------
>
> Key: DBCP-305
> URL: https://issues.apache.org/jira/browse/DBCP-305
> Project: Commons Dbcp
> Issue Type: Improvement
> Reporter: Christopher Schultz
> Priority: Trivial
>
> 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.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (DBCP-305) Use API-specific exception for logging
abandoned objects
Posted by "Mark Thomas (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/DBCP-305?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Mark Thomas updated DBCP-305:
-----------------------------
Fix Version/s: 1.3
Assignee: Mark Thomas
> Use API-specific exception for logging abandoned objects
> --------------------------------------------------------
>
> Key: DBCP-305
> URL: https://issues.apache.org/jira/browse/DBCP-305
> Project: Commons Dbcp
> Issue Type: Improvement
> Reporter: Christopher Schultz
> Assignee: Mark Thomas
> Priority: Trivial
> Fix For: 1.3
>
> Attachments: DBCP-305.diff
>
>
> 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.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (DBCP-305) Use API-specific exception for logging
abandoned objects
Posted by "Christopher Schultz (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/DBCP-305?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Christopher Schultz updated DBCP-305:
-------------------------------------
Attachment: DBCP-305.diff
Proposed patch to a) use an API-specific exception type and b) include the timestamp in the exception message
The result is that logged exceptions are (hopefully) easier to locate and read in log files.
I used a static inner class to simplify the patch, but you guys are free to split-apart the classes if you choose.
> Use API-specific exception for logging abandoned objects
> --------------------------------------------------------
>
> Key: DBCP-305
> URL: https://issues.apache.org/jira/browse/DBCP-305
> Project: Commons Dbcp
> Issue Type: Improvement
> Reporter: Christopher Schultz
> Priority: Trivial
> Attachments: DBCP-305.diff
>
>
> 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.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.