BATCH-2412 Add guards around debug statements

In various places in the code base a debug message is constructed
unconditionally. This adds unnecessary overhead in the common case when
debug logging is off.

 - add guards around debug statements in non-test code

Issue: BATCH-2412
This commit is contained in:
Philippe Marschall
2015-08-04 08:46:54 +02:00
committed by Michael Minella
parent 7ec7152c5e
commit 3783345c55
26 changed files with 153 additions and 53 deletions

View File

@@ -169,7 +169,10 @@ public class StoredProcedureItemReader<T> extends AbstractCursorItemReader<T> {
SqlParameter cursorParameter = callContext.createReturnResultSetParameter("cursor", rowMapper);
this.callString = callContext.createCallString();
log.debug("Call string is: " + callString);
if (log.isDebugEnabled()) {
log.debug("Call string is: " + callString);
}
int cursorSqlType = Types.OTHER;
if (function) {

View File

@@ -558,7 +558,9 @@ ResourceAwareItemWriterItemStream<T>, InitializingBean {
if (key.contains(":")) {
prefix = key.substring(key.indexOf(":") + 1);
}
log.debug("registering prefix: " +prefix + "=" + entry.getValue());
if (log.isDebugEnabled()) {
log.debug("registering prefix: " +prefix + "=" + entry.getValue());
}
writer.setPrefix(prefix, entry.getValue());
}
}

View File

@@ -84,9 +84,11 @@ public abstract class StaxUtils {
staxResultClassCtorOnSpringWs15 = staxResultClassOnSpringWs15.getConstructor(XMLEventWriter.class);
} else {
logger.debug("'StaxSource' was not detected in Spring 3.0's OXM support or Spring WS 1.5's OXM support. " +
"This is a problem if you intend to use the " +StaxEventItemWriter.class.getName() + " or " +
StaxEventItemReader.class.getName()+". Please add the appropriate dependencies.");
if (logger.isDebugEnabled()) {
logger.debug("'StaxSource' was not detected in Spring 3.0's OXM support or Spring WS 1.5's OXM support. " +
"This is a problem if you intend to use the " +StaxEventItemWriter.class.getName() + " or " +
StaxEventItemReader.class.getName()+". Please add the appropriate dependencies.");
}
}
} catch (Exception ex) {

View File

@@ -249,8 +249,10 @@ public class RepeatTemplate implements RepeatOperations {
if (!deferred.isEmpty()) {
Throwable throwable = deferred.iterator().next();
logger.debug("Handling fatal exception explicitly (rethrowing first of " + deferred.size() + "): "
+ throwable.getClass().getName() + ": " + throwable.getMessage());
if (logger.isDebugEnabled()) {
logger.debug("Handling fatal exception explicitly (rethrowing first of " + deferred.size() + "): "
+ throwable.getClass().getName() + ": " + throwable.getMessage());
}
rethrow(throwable);
}
@@ -285,12 +287,16 @@ public class RepeatTemplate implements RepeatOperations {
RepeatListener interceptor = listeners[i];
// This is not an error - only log at debug
// level.
logger.debug("Exception intercepted (" + (i + 1) + " of " + listeners.length + ")", unwrappedThrowable);
if (logger.isDebugEnabled()) {
logger.debug("Exception intercepted (" + (i + 1) + " of " + listeners.length + ")", unwrappedThrowable);
}
interceptor.onError(context, unwrappedThrowable);
}
logger.debug("Handling exception: " + throwable.getClass().getName() + ", caused by: "
+ unwrappedThrowable.getClass().getName() + ": " + unwrappedThrowable.getMessage());
if (logger.isDebugEnabled()) {
logger.debug("Handling exception: " + throwable.getClass().getName() + ", caused by: "
+ unwrappedThrowable.getClass().getName() + ": " + unwrappedThrowable.getMessage());
}
exceptionHandler.handleException(context, unwrappedThrowable);
}

View File

@@ -34,7 +34,9 @@ public class ResourcelessTransactionManager extends AbstractPlatformTransactionM
@Override
protected void doCommit(DefaultTransactionStatus status) throws TransactionException {
logger.debug("Committing resourceless transaction on [" + status.getTransaction() + "]");
if (logger.isDebugEnabled()) {
logger.debug("Committing resourceless transaction on [" + status.getTransaction() + "]");
}
}
@Override
@@ -56,7 +58,9 @@ public class ResourcelessTransactionManager extends AbstractPlatformTransactionM
@Override
protected void doRollback(DefaultTransactionStatus status) throws TransactionException {
logger.debug("Rolling back resourceless transaction on [" + status.getTransaction() + "]");
if (logger.isDebugEnabled()) {
logger.debug("Rolling back resourceless transaction on [" + status.getTransaction() + "]");
}
}
@Override