Author: steve.ebersole(a)jboss.com
Date: 2010-07-21 13:31:09 -0400 (Wed, 21 Jul 2010)
New Revision: 19994
Modified:
core/trunk/core/src/main/java/org/hibernate/id/enhanced/OptimizerFactory.java
Log:
HHH-3001 - The NoopOptimizer is not thread safe
Modified: core/trunk/core/src/main/java/org/hibernate/id/enhanced/OptimizerFactory.java
===================================================================
---
core/trunk/core/src/main/java/org/hibernate/id/enhanced/OptimizerFactory.java 2010-07-21
17:29:50 UTC (rev 19993)
+++
core/trunk/core/src/main/java/org/hibernate/id/enhanced/OptimizerFactory.java 2010-07-21
17:31:09 UTC (rev 19994)
@@ -187,15 +187,14 @@
* {@inheritDoc}
*/
public Serializable generate(AccessCallback callback) {
- if ( lastSourceValue == null ) {
- do {
- lastSourceValue = callback.getNextValue();
- } while ( lastSourceValue.lt( 1 ) );
+ // IMPL NOTE : it is incredibly important that the method-local variable be used here
to
+ // avoid concurrency issues.
+ IntegralDataTypeHolder value = null;
+ while ( value == null || value.lt( 1 ) ) {
+ value = callback.getNextValue();
}
- else {
- lastSourceValue = callback.getNextValue();
- }
- return lastSourceValue.makeValue();
+ lastSourceValue = value;
+ return value.makeValue();
}
/**
Show replies by date