commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gl...@apache.org
Subject cvs commit: jakarta-commons/dbcp/src/java/org/apache/commons/dbcp AbandonedTrace.java
Date Thu, 20 Jun 2002 00:16:51 GMT
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:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message