db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Henning P. Schmiedehausen" <...@intermeta.de>
Subject Re: cvs commit: db-torque/src/java/org/apache/torque/util BasePeer.java
Date Sat, 19 Jul 2003 23:58:36 GMT
jmcnally@apache.org writes:

>jmcnally    2003/07/19 11:49:40

This is a gross hack.

Make Transaction.rollback(Connection con) accept "null" as connection
and just return. 

Not start hacking in lots of tests where you're bound to miss one or
two and then developers looking at the Torque code start to scratch
their head and ask themselves "why did he do this on five occasions
and missed two others"?

I'm strictly -1 on this change because I've removed lots of such bogus
code from Turbine.

	Regards
		Henning



>  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

-- 
Dipl.-Inf. (Univ.) Henning P. Schmiedehausen          INTERMETA GmbH
hps@intermeta.de        +49 9131 50 654 0   http://www.intermeta.de/

Java, perl, Solaris, Linux, xSP Consulting, Web Services 
freelance consultant -- Jakarta Turbine Development  -- hero for hire

--- Quote of the week: "It is pointless to tell people anything when
you know that they won't process the message." --- Jonathan Revusky

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