Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@apache.org Received: (qmail 50455 invoked from network); 20 Jun 2002 00:16:58 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 20 Jun 2002 00:16:58 -0000 Received: (qmail 5123 invoked by uid 97); 20 Jun 2002 00:17:08 -0000 Delivered-To: qmlist-jakarta-archive-commons-dev@jakarta.apache.org Received: (qmail 5077 invoked by uid 97); 20 Jun 2002 00:17:08 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 5066 invoked by uid 97); 20 Jun 2002 00:17:07 -0000 X-Antivirus: nagoya (v4198 created Apr 24 2002) Date: 20 Jun 2002 00:16:51 -0000 Message-ID: <20020620001651.5404.qmail@icarus.apache.org> From: glenn@apache.org To: jakarta-commons-cvs@apache.org Subject: cvs commit: jakarta-commons/dbcp/src/java/org/apache/commons/dbcp AbandonedTrace.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N glenn 2002/06/19 17:16:51 Modified: dbcp/src/java/org/apache/commons/dbcp AbandonedTrace.java Log: The Exception stack trace for an abondoned connections gets generated when the connection is opened. But the abandoned connection can be reported and logged hours later. Added a datestamp for when the db connection was created so that it is easier to correlate the abandoned connection to the request which created it. Revision Changes Path 1.2 +15 -9 jakarta-commons/dbcp/src/java/org/apache/commons/dbcp/AbandonedTrace.java Index: AbandonedTrace.java =================================================================== RCS file: /home/cvs/jakarta-commons/dbcp/src/java/org/apache/commons/dbcp/AbandonedTrace.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- AbandonedTrace.java 16 May 2002 21:25:37 -0000 1.1 +++ AbandonedTrace.java 20 Jun 2002 00:16:51 -0000 1.2 @@ -60,6 +60,7 @@ */ package org.apache.commons.dbcp; +import java.text.SimpleDateFormat; import java.util.Date; import java.util.Iterator; import java.util.List; @@ -78,8 +79,9 @@ */ public class AbandonedTrace { - private static String MESSAGE = - "DBCP object was created, but never closed by the following code: "; + private static SimpleDateFormat format = new SimpleDateFormat + ("'DBCP object created' yyyy-mm-dd HH:mm:ss " + + "'by the following code was never closed:'"); // DBCP AbandonedConfig private AbandonedConfig config = null; @@ -87,6 +89,7 @@ private AbandonedTrace parent; // A stack trace of the code that created me (if in debug mode) **/ private Exception createdBy; + private Date createdDate; // A list of objects created by children of this object private List trace = new FastArrayList(); // Last time this connection was used @@ -135,7 +138,8 @@ return; } if (config.getLogAbandoned()) { - createdBy = new Exception(MESSAGE); + createdBy = new Exception(); + createdDate = new Date(); } } @@ -195,8 +199,9 @@ return; } if (config.getLogAbandoned()) { - createdBy = new Exception(MESSAGE); - } + createdBy = new Exception(); + createdDate = new Date(); + } if (parent != null) { parent.addTrace(this); } @@ -238,6 +243,7 @@ */ public void printStackTrace() { if (createdBy != null) { + System.out.println(format.format(createdDate)); createdBy.printStackTrace(); } Iterator it = trace.iterator(); -- To unsubscribe, e-mail: For additional commands, e-mail: