[hibernate-commits] Hibernate SVN: r19993 - core/branches/Branch_3_5/core/src/main/java/org/hibernate/id/enhanced.

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Wed Jul 21 13:29:51 EDT 2010


Author: steve.ebersole at jboss.com
Date: 2010-07-21 13:29:50 -0400 (Wed, 21 Jul 2010)
New Revision: 19993

Modified:
   core/branches/Branch_3_5/core/src/main/java/org/hibernate/id/enhanced/OptimizerFactory.java
Log:
HHH-3001 - The NoopOptimizer is not thread safe


Modified: core/branches/Branch_3_5/core/src/main/java/org/hibernate/id/enhanced/OptimizerFactory.java
===================================================================
--- core/branches/Branch_3_5/core/src/main/java/org/hibernate/id/enhanced/OptimizerFactory.java	2010-07-21 15:55:41 UTC (rev 19992)
+++ core/branches/Branch_3_5/core/src/main/java/org/hibernate/id/enhanced/OptimizerFactory.java	2010-07-21 17:29:50 UTC (rev 19993)
@@ -186,15 +186,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();
 		}
 
 		/**



More information about the hibernate-commits mailing list