HHH-10358 Make sure synchronization on AbstractLoadPlanBasedLoader is skipped when the guarded feature is disabled

This commit is contained in:
Sanne Grinovero 2015-12-14 16:15:40 +00:00
parent 971783607e
commit 90ac42fa2c
1 changed files with 10 additions and 5 deletions

View File

@ -25,6 +25,7 @@ import org.hibernate.dialect.pagination.LimitHelper;
import org.hibernate.dialect.pagination.NoopLimitHandler;
import org.hibernate.engine.jdbc.ColumnNameCache;
import org.hibernate.engine.jdbc.spi.JdbcServices;
import org.hibernate.engine.jdbc.spi.ResultSetWrapper;
import org.hibernate.engine.spi.PersistenceContext;
import org.hibernate.engine.spi.QueryParameters;
import org.hibernate.engine.spi.RowSelection;
@ -468,18 +469,22 @@ public abstract class AbstractLoadPlanBasedLoader {
}
}
private synchronized ResultSet wrapResultSetIfEnabled(final ResultSet rs, final SessionImplementor session) {
// synchronized to avoid multi-thread access issues; defined as method synch to avoid
// potential deadlock issues due to nature of code.
private ResultSet wrapResultSetIfEnabled(final ResultSet rs, final SessionImplementor session) {
if ( session.getFactory().getSessionFactoryOptions().isWrapResultSetsEnabled() ) {
try {
if ( log.isDebugEnabled() ) {
log.debugf( "Wrapping result set [%s]", rs );
}
return session.getFactory()
ResultSetWrapper wrapper = session.getFactory()
.getServiceRegistry()
.getService( JdbcServices.class )
.getResultSetWrapper().wrap( rs, retreiveColumnNameToIndexCache( rs ) );
.getResultSetWrapper();
// synchronized to avoid multi-thread access issues
// Apparently the comment about this needing synchronization was introduced when AbstractLoadPlanBasedLoader first appeared
// in version control. Would need to investigate if it's still needed?
synchronized ( this ) {
return wrapper.wrap( rs, retreiveColumnNameToIndexCache( rs ) );
}
}
catch(SQLException e) {
log.unableToWrapResultSet( e );