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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to