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
Date Sat, 19 Jul 2003 18:49:40 GMT
jmcnally    2003/07/19 11:49:40

  Modified:    src/java/org/apache/torque/util BasePeer.java
  Log:
  replaced
  
  catch (TorqueException e)
  {
      Transaction.rollback(con);
      throw e;
  }
  
  with
  
  catch (TorqueException e)
  {
      if (con != null)  Transaction.rollback(con);
      throw e;
  }
  
  so that an exception which prevents getting a connection does not get
  obscured by the attempt to use the connection in rollback.
  
  Revision  Changes    Path
  1.72      +26 -12    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.71
  retrieving revision 1.72
  diff -u -r1.71 -r1.72
  --- BasePeer.java	25 Jun 2003 19:31:16 -0000	1.71
  +++ BasePeer.java	19 Jul 2003 18:49:40 -0000	1.72
  @@ -435,7 +435,10 @@
           }
           catch (TorqueException e)
           {
  -            Transaction.rollback(con);
  +            if (con != null) 
  +            {
  +                Transaction.rollback(con);   
  +            }
               throw new TorqueException(e);
           }
       }
  @@ -625,7 +628,10 @@
           }
           catch (TorqueException e)
           {
  -            Transaction.rollback(con);
  +            if (con != null) 
  +            {
  +                Transaction.rollback(con);   
  +            }
               throw e;
           }
   
  @@ -1352,7 +1358,10 @@
           }
           catch (Exception e)
           {
  -            Transaction.rollback(con);
  +            if (con != null) 
  +            {
  +                Transaction.rollback(con);   
  +            }
               throw new TorqueException(e);
           }
           return results;
  @@ -1743,7 +1752,10 @@
           }
           catch (TorqueException e)
           {
  -            Transaction.rollback(con);
  +            if (con != null) 
  +            {
  +                Transaction.rollback(con);   
  +            }
               throw e;
           }
       }
  @@ -1806,18 +1818,20 @@
       public static void doUpdate(Criteria selectCriteria, Criteria updateValues)
           throws TorqueException
       {
  -        Connection db = null;
  +        Connection con = null;
           try
           {
  -            db = Transaction.beginOptional(
  -                    selectCriteria.getDbName(),
  -                    updateValues.isUseTransaction());
  -            doUpdate(selectCriteria, updateValues, db);
  -            Transaction.commit(db);
  +            con = Transaction.beginOptional(selectCriteria.getDbName(),
  +                                            updateValues.isUseTransaction());
  +            doUpdate(selectCriteria, updateValues, con);
  +            Transaction.commit(con);
           }
           catch (TorqueException e)
           {
  -            Transaction.rollback(db);
  +            if (con != null) 
  +            {
  +                Transaction.rollback(con);   
  +            }
               throw 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