Always guard for Log level before producing log message parameters

This commit is contained in:
Sanne Grinovero 2022-03-16 20:57:16 +00:00 committed by Sanne Grinovero
parent 6ab1cd3434
commit 6169a60ecd
2 changed files with 22 additions and 13 deletions

View File

@ -13,6 +13,8 @@ import org.hibernate.query.spi.NavigablePath;
import org.hibernate.sql.ast.SqlTreeCreationLogger; import org.hibernate.sql.ast.SqlTreeCreationLogger;
import org.hibernate.sql.ast.tree.from.TableGroup; import org.hibernate.sql.ast.tree.from.TableGroup;
import org.jboss.logging.Logger;
/** /**
* Simple implementation of FromClauseAccess * Simple implementation of FromClauseAccess
* *
@ -47,15 +49,19 @@ public class SimpleFromClauseAccessImpl implements FromClauseAccess {
@Override @Override
public void registerTableGroup(NavigablePath navigablePath, TableGroup tableGroup) { public void registerTableGroup(NavigablePath navigablePath, TableGroup tableGroup) {
SqlTreeCreationLogger.LOGGER.debugf( final Logger logger = SqlTreeCreationLogger.LOGGER;
final boolean debugEnabled = logger.isDebugEnabled();
if ( debugEnabled ) {
logger.debugf(
"Registration of TableGroup [%s] with identifierForTableGroup [%s] for NavigablePath [%s] ", "Registration of TableGroup [%s] with identifierForTableGroup [%s] for NavigablePath [%s] ",
tableGroup, tableGroup,
tableGroup.getNavigablePath().getIdentifierForTableGroup(), tableGroup.getNavigablePath().getIdentifierForTableGroup(),
navigablePath.getIdentifierForTableGroup() navigablePath.getIdentifierForTableGroup()
); );
}
final TableGroup previous = tableGroupMap.put( navigablePath, tableGroup ); final TableGroup previous = tableGroupMap.put( navigablePath, tableGroup );
if ( previous != null ) { if ( debugEnabled && previous != null ) {
SqlTreeCreationLogger.LOGGER.debugf( logger.debugf(
"Registration of TableGroup [%s] for NavigablePath [%s] overrode previous registration : %s", "Registration of TableGroup [%s] for NavigablePath [%s] overrode previous registration : %s",
tableGroup, tableGroup,
navigablePath, navigablePath,

View File

@ -32,13 +32,16 @@ public class SqlTuple implements Expression, SqlTupleContainer, DomainResultProd
this.expressions = expressions; this.expressions = expressions;
this.valueMapping = valueMapping; this.valueMapping = valueMapping;
if ( expressions.size() < 2 ) { if ( SqlTreeCreationLogger.LOGGER.isDebugEnabled() ) {
final int size = expressions.size();
if ( size < 2 ) {
SqlTreeCreationLogger.LOGGER.debugf( SqlTreeCreationLogger.LOGGER.debugf(
"SqlTuple created with `%s` expression(s)", "SqlTuple created with `%s` expression(s)",
expressions.size() size
); );
} }
} }
}
@Override @Override
public MappingModelExpressible getExpressionType() { public MappingModelExpressible getExpressionType() {