Browse Source

Extract isDebugEnabled() checks to local variables

Closes gh-24683
pull/24707/head
Qimiao Chen 6 years ago committed by GitHub
parent
commit
5f2e298c08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      spring-jdbc/src/main/java/org/springframework/jdbc/datasource/DataSourceUtils.java

10
spring-jdbc/src/main/java/org/springframework/jdbc/datasource/DataSourceUtils.java

@ -178,10 +178,11 @@ public abstract class DataSourceUtils { @@ -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 { @@ -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 { @@ -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 { @@ -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…
Cancel
Save