Extract isDebugEnabled() checks to local variables
Closes gh-24683
This commit is contained in:
parent
193a76fe2a
commit
5f2e298c08
|
|
@ -178,10 +178,11 @@ public abstract class DataSourceUtils {
|
|||
|
||||
Assert.notNull(con, "No Connection specified");
|
||||
|
||||
boolean debugEnabled = logger.isDebugEnabled();
|
||||
// Set read-only flag.
|
||||
if (definition != null && definition.isReadOnly()) {
|
||||
try {
|
||||
if (logger.isDebugEnabled()) {
|
||||
if (debugEnabled) {
|
||||
logger.debug("Setting JDBC Connection [" + con + "] read-only");
|
||||
}
|
||||
con.setReadOnly(true);
|
||||
|
|
@ -203,7 +204,7 @@ public abstract class DataSourceUtils {
|
|||
// Apply specific isolation level, if any.
|
||||
Integer previousIsolationLevel = null;
|
||||
if (definition != null && definition.getIsolationLevel() != TransactionDefinition.ISOLATION_DEFAULT) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
if (debugEnabled) {
|
||||
logger.debug("Changing isolation level of JDBC Connection [" + con + "] to " +
|
||||
definition.getIsolationLevel());
|
||||
}
|
||||
|
|
@ -232,10 +233,11 @@ public abstract class DataSourceUtils {
|
|||
Connection con, @Nullable Integer previousIsolationLevel, boolean resetReadOnly) {
|
||||
|
||||
Assert.notNull(con, "No Connection specified");
|
||||
boolean debugEnabled = logger.isDebugEnabled();
|
||||
try {
|
||||
// Reset transaction isolation to previous value, if changed for the transaction.
|
||||
if (previousIsolationLevel != null) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
if (debugEnabled) {
|
||||
logger.debug("Resetting isolation level of JDBC Connection [" +
|
||||
con + "] to " + previousIsolationLevel);
|
||||
}
|
||||
|
|
@ -244,7 +246,7 @@ public abstract class DataSourceUtils {
|
|||
|
||||
// Reset read-only flag if we originally switched it to true on transaction begin.
|
||||
if (resetReadOnly) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
if (debugEnabled) {
|
||||
logger.debug("Resetting read-only flag of JDBC Connection [" + con + "]");
|
||||
}
|
||||
con.setReadOnly(false);
|
||||
|
|
|
|||
Loading…
Reference in New Issue