HHH-3001 - The NoopOptimizer is not thread safe

git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@19994 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
Steve Ebersole 2010-07-21 17:31:09 +00:00
parent 48a5e04caa
commit 7f815de1a7
1 changed files with 7 additions and 8 deletions

View File

@ -187,15 +187,14 @@ public class OptimizerFactory {
* {@inheritDoc} * {@inheritDoc}
*/ */
public Serializable generate(AccessCallback callback) { public Serializable generate(AccessCallback callback) {
if ( lastSourceValue == null ) { // IMPL NOTE : it is incredibly important that the method-local variable be used here to
do { // avoid concurrency issues.
lastSourceValue = callback.getNextValue(); IntegralDataTypeHolder value = null;
} while ( lastSourceValue.lt( 1 ) ); while ( value == null || value.lt( 1 ) ) {
value = callback.getNextValue();
} }
else { lastSourceValue = value;
lastSourceValue = callback.getNextValue(); return value.makeValue();
}
return lastSourceValue.makeValue();
} }
/** /**