db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmcna...@apache.org
Subject cvs commit: db-torque/src/java/org/apache/torque/util BasePeer.java Transaction.java
Date Sun, 03 Aug 2003 17:41:04 GMT
jmcnally    2003/08/03 10:41:04

  Modified:    src/java/org/apache/torque/util BasePeer.java
                        Transaction.java
  Log:
  * src/java/org/apache/torque/util/BasePeer.java -
    replace null Connection checks wrapping
    Transaction.rollback with Transaction.safeRollback.
  * src/java/org/apache/torque/util/Transaction.java - rollback method changed
    to throw TorqueException instead of NPE when Connection is null.
    safeRollback method changed to log null Connection at debug level, since it
    is a normal event. Lowered other exception logging to warn level since
    safeRollback should not be called if a failed rollback is considered a
    serious error.
  
  Revision  Changes    Path
  1.74      +6 -21     db-torque/src/java/org/apache/torque/util/BasePeer.java
  
  Index: BasePeer.java
  ===================================================================
  RCS file: /home/cvs/db-torque/src/java/org/apache/torque/util/BasePeer.java,v
  retrieving revision 1.73
  retrieving revision 1.74
  diff -u -r1.73 -r1.74
  --- BasePeer.java	19 Jul 2003 19:26:33 -0000	1.73
  +++ BasePeer.java	3 Aug 2003 17:41:04 -0000	1.74
  @@ -448,10 +448,7 @@
           }
           catch (TorqueException e)
           {
  -            if (con != null) 
  -            {
  -                Transaction.rollback(con);   
  -            }
  +            Transaction.safeRollback(con);
               throw e;
           }
       }
  @@ -641,10 +638,7 @@
           }
           catch (TorqueException e)
           {
  -            if (con != null) 
  -            {
  -                Transaction.rollback(con);   
  -            }
  +            Transaction.safeRollback(con);
               throw e;
           }
   
  @@ -1371,10 +1365,7 @@
           }
           catch (Exception e)
           {
  -            if (con != null) 
  -            {
  -                Transaction.rollback(con);   
  -            }
  +            Transaction.safeRollback(con);
               throwTorqueException(e);
           }
           return results;
  @@ -1765,10 +1756,7 @@
           }
           catch (TorqueException e)
           {
  -            if (con != null) 
  -            {
  -                Transaction.rollback(con);   
  -            }
  +            Transaction.safeRollback(con);
               throw e;
           }
       }
  @@ -1841,10 +1829,7 @@
           }
           catch (TorqueException e)
           {
  -            if (con != null) 
  -            {
  -                Transaction.rollback(con);   
  -            }
  +            Transaction.safeRollback(con);
               throw e;
           }
       }
  
  
  
  1.9       +18 -9     db-torque/src/java/org/apache/torque/util/Transaction.java
  
  Index: Transaction.java
  ===================================================================
  RCS file: /home/cvs/db-torque/src/java/org/apache/torque/util/Transaction.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- Transaction.java	18 May 2003 12:27:24 -0000	1.8
  +++ Transaction.java	3 Aug 2003 17:41:04 -0000	1.9
  @@ -182,7 +182,7 @@
       {
           if (con == null)
           {
  -            log.error("Connection object was null. "
  +            throw new TorqueException("Connection object was null. "
                       + "This could be due to a misconfiguration of the "
                       + "DataSourceFactory. Check the logs and Torque.properties "
                       + "to better determine the cause.");
  @@ -214,19 +214,28 @@
   
       /**
        * Roll back a transaction without throwing errors if they occur.
  -     *
  +     * A null Connection argument is logged at the debug level and other
  +     * errors are logged at warn level.
  +     * 
        * @param con The Connection for the transaction.
        * @see safeRollback
        */
  -    public static void safeRollback(Connection con)
  +    public static void safeRollback(Connection con) 
       {
  -        try
  +        if (con == null) 
           {
  -            Transaction.rollback(con);
  +            log.debug("called safeRollback with null argument");
           }
  -        catch (TorqueException e)
  +        else 
           {
  -            log.error("An error occured during rollback.", e);
  -        }
  +            try
  +            {
  +                Transaction.rollback(con);
  +            }
  +            catch (TorqueException e)
  +            {
  +                log.warn("An error occured during rollback.", e);
  +            }
  +        }   
       }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


Mime
View raw message