Skip to content

Commit 8ad5dde

Browse files
committed
HHH-8680 Relax synchronized block in TableGenerator#generate
1 parent 47114c3 commit 8ad5dde

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

hibernate-core/src/main/java/org/hibernate/id/enhanced/OptimizerFactory.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,16 +235,21 @@ public final int getIncrementSize() {
235235
/**
236236
* An optimizer that performs no optimization. The database is hit for
237237
* every request.
238+
*
239+
* @deprecated This is the fallback Optimizer chosen when we fail to instantiate one
240+
* of the proper implementations. Using this implementation is probably a performance
241+
* problem.
238242
*/
239-
public static class NoopOptimizer extends OptimizerSupport {
240-
private IntegralDataTypeHolder lastSourceValue;
243+
@Deprecated
244+
public static final class NoopOptimizer extends OptimizerSupport {
245+
private volatile IntegralDataTypeHolder lastSourceValue;
241246

242247
public NoopOptimizer(Class returnClass, int incrementSize) {
243248
super( returnClass, incrementSize );
244249
}
245250

246251
@Override
247-
public Serializable generate(AccessCallback callback) {
252+
public synchronized Serializable generate(AccessCallback callback) {
248253
// IMPL NOTE : it is incredibly important that the method-local variable be used here to
249254
// avoid concurrency issues.
250255
IntegralDataTypeHolder value = null;

0 commit comments

Comments
 (0)