You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-dev@db.apache.org by BoonThai Hoh <hb...@swiftinnovation.com> on 2003/07/22 23:28:24 UTC
safeRollback problem
Hi,
I am looking at Transaction.safeRollback in 3.0 and 3.0.2 and am running
into errors that did not exist in the alpha build.
However, it simply calls Transaction.rollback(con) which can throws
NullPointerException if con is null. This breaks alot of my code since I
use safeRollback extensively for precautionary measure. Furthermore, the
signature for rollback declare that TorqueException will be thrown and does
not specify NullPointerException.
Is this a bug? or is there logic to this?
Thanks,
BT
public static void rollback(Connection con) throws TorqueException
{
if (con == null)
{
throw new NullPointerException(
"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.");
}
try
{
if (con.getMetaData().supportsTransactions()
&& con.getAutoCommit() == false)
{
con.rollback();
con.setAutoCommit(true);
}
}
catch (SQLException e)
{
category.error(
"An attempt was made to rollback a transaction "
+ "but the database did not allow the operation to be "
+ "rolled back.",
e);
throw new TorqueException(e);
}
finally
{
Torque.closeConnection(con);
}
}
public static void safeRollback(Connection con)
{
try
{
Transaction.rollback(con);
}
catch (TorqueException e)
{
category.error("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
Re: safeRollback problem
Posted by Scott Eade <se...@backstagetech.com.au>.
BoonThai Hoh wrote:
> However, it simply calls Transaction.rollback(con) which can throws
> NullPointerException if con is null. This breaks alot of my code since
> I use safeRollback extensively for precautionary measure. Furthermore,
> the signature for rollback declare that TorqueException will be thrown
> and does not specify NullPointerException.
I think this issue has been partly dealt with by a recent commit by John
McNally just a couple of days ago. I say partially because the
implementation was not ideal and needs to be updated as per Henning's
reply to this list. The suggested behaviour is for rollback(con) to
simply return when con is null.
Scott
--
Scott Eade
Backstage Technologies Pty. Ltd.
http://www.backstagetech.com.au
---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org