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:23:39 GMT
jmcnally    2003/08/03 10:23:39

  Modified:    src/java/org/apache/torque/util Tag: TORQUE_3_0_BRANCH
                        BasePeer.java Transaction.java *
                        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.
  Log:
  
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.55.2.4  +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.55.2.3
  retrieving revision 1.55.2.4
  diff -u -r1.55.2.3 -r1.55.2.4
  --- BasePeer.java	19 Jul 2003 21:10:15 -0000	1.55.2.3
  +++ BasePeer.java	3 Aug 2003 17:23:38 -0000	1.55.2.4
  @@ -425,10 +425,7 @@
           }
           catch (TorqueException e)
           {
  -            if (con != null) 
  -            {
  -                Transaction.rollback(con);
  -            }
  +            Transaction.safeRollback(con);
               throw e;
           }
       }
  @@ -620,10 +617,7 @@
           }
           catch (TorqueException e)
           {
  -            if (con != null) 
  -            {
  -                Transaction.rollback(con);
  -            }
  +            Transaction.safeRollback(con);
               throw e;
           }
   
  @@ -1375,10 +1369,7 @@
           }
           catch (Exception e)
           {
  -            if (con != null) 
  -            {
  -                Transaction.rollback(con);
  -            }
  +            Transaction.safeRollback(con);
               throw new TorqueException(e);
           }
   
  @@ -1748,10 +1739,7 @@
           }
           catch (TorqueException e)
           {
  -            if (con != null) 
  -            {
  -                Transaction.rollback(con);
  -            }
  +            Transaction.safeRollback(con);
               throw e;
           }
       }
  @@ -1825,10 +1813,7 @@
           }
           catch (TorqueException e)
           {
  -            if (db != null) 
  -            {
  -                Transaction.rollback(db);
  -            }
  +            Transaction.safeRollback(db);
               throw e;
           }
       }
  
  
  
  1.2.2.1   +16 -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.2
  retrieving revision 1.2.2.1
  diff -u -r1.2 -r1.2.2.1
  --- Transaction.java	14 Aug 2002 12:10:45 -0000	1.2
  +++ Transaction.java	3 Aug 2003 17:23:38 -0000	1.2.2.1
  @@ -176,7 +176,7 @@
       {
           if (con == null)
           {
  -            throw new NullPointerException(
  +            throw new TorqueException(
                   "Connection object was null. "
                       + "This could be due to a misconfiguration of the "
                       + "DataSourceFactory. Check the logs and Torque.properties "
  @@ -210,21 +210,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) 
       {
  -        try
  +        if (con == null) 
           {
  -            Transaction.rollback(con);
  +            category.debug("called safeRollback with null argument");
           }
  -        catch (TorqueException e)
  +        else 
           {
  -            category.error("An error occured during rollback.", e);
  -        }
  +            try
  +            {
  +                Transaction.rollback(con);
  +            }
  +            catch (TorqueException e)
  +            {
  +                category.warn("An error occured during rollback.", e);
  +            }
  +        }   
       }
  -
  -
   }
  
  
  
  No                   revision
  
  
                       
  
  
  No                   revision
  
  
  No                   revision
  
  
  No                   revision
  
  
  No                   revision
  
  
  No                   revision
  
  
  No                   revision
  
  
  No                   revision
  
  
  No                   revision
  
  
  No                   revision
  
  
  No                   revision
  
  
                       
  
  
  No                   revision
  
  
  No                   revision
  
  
  No                   revision
  
  
  No                   revision
  
  
  No                   revision
  
  
  No                   revision
  
  
  No                   revision
  
  
  No                   revision
  
  
  No                   revision
  
  
  No                   revision
  
  
  No                   revision
  
  
  No                   revision
  
  
  No                   revision
  
  
  No                   revision
  
  
  No                   revision
  
  
  No                   revision
  
  
  No                   revision
  
  
  No                   revision
  
  
  No                   revision
  
  
  No                   revision
  
  
  No                   revision
  
  
  No                   revision
  
  
  No                   revision
  
  
  No                   revision
  
  
  No                   revision
  
  
  No                   revision
  
  
  No                   revision
  
  
  No                   revision
  
  
  No                   revision
  
  
  No                   revision
  
  
  No                   revision
  
  
  No                   revision
  
  
  No                   revision
  
  
  No                   revision
  
  
  No                   revision
  
  
  No                   revision
  
  
  No                   revision
  
  
  No                   revision
  
  
  No                   revision
  
  
  No                   revision
  
  
  No                   revision
  
  
  No                   revision
  
  
  No                   revision
  
  
  No                   revision
  
  
  No                   revision
  
  
  No                   revision
  
  
  No                   revision
  
  
  No                   revision
  
  
  No                   revision
  
  
  No                   revision
  
  
  No                   revision
  
  
  No                   revision
  
  

---------------------------------------------------------------------
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