|
From: Oliver H. <Oli...@ou...> - 2004-01-08 04:35:27
|
Hi,
Just putting this one out there.
// -------- Start Code --------
private void onThrowable(MethodInvocation invocation,
TransactionAttribute txAtt, TransactionStatus status, Throwable ex) {
if (txAtt.rollbackOn(ex)) {
logger.error("Invoking rollback for transaction on method '" +
invocation.getMethod().getName() +
"' due to throwable [" + ex + "]");
try {
this.transactionManager.rollback(status);
}
catch (TransactionException tex) {
logger.error("Application exception overridden by rollback
exception", ex);
throw tex;
}
}
else {
if (logger.isDebugEnabled())
logger.debug("Method '" + invocation.getMethod().getName()+ "' threw
throwable [" + ex +
"] but this does not force transaction rollback");
// Will still roll back if rollbackOnly is true
this.transactionManager.commit(status);
}
}
// -------- End Code --------
Is it really appropriate for the TransactionInterceptor.onThrowable(...)
method to log the fact that an exception has caused a rollback at level
ERROR?=20
I would have thought the ERROR level would only be used in places where
a runtime error or unexpected conditions has been detected. What's
happening in the TransactionInterceptor is exactly what should be
happening given its configuration.=20
IMHO it should really be at DEBUG or TRACE level.
What do you think?
Ollie
|