Skip to content

Commit 42967a1

Browse files
committed
proposed fix for #707
make sure that queued requests use the right session and entity args
1 parent d178627 commit 42967a1

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

hibernate-reactive-core/src/main/java/org/hibernate/reactive/id/impl/BlockingIdentifierGenerator.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public abstract class BlockingIdentifierGenerator implements ReactiveIdentifierG
3838
private int loValue;
3939
private long hiValue;
4040

41-
private volatile List<CompletableFuture<Long>> queue = null;
41+
private volatile List<Runnable> queue = null;
4242

4343
protected synchronized long next() {
4444
return loValue>0 && loValue<getBlockSize()
@@ -70,7 +70,7 @@ public CompletionStage<Long> generate(ReactiveConnectionSupplier session, Object
7070
// go off and fetch the next hi value from db
7171
nextHiValue(session).thenAccept( id -> {
7272
// Vertx.currentContext().runOnContext(v -> {
73-
List<CompletableFuture<Long>> list;
73+
List<Runnable> list;
7474
synchronized (this) {
7575
// clone ref to the queue
7676
list = queue;
@@ -79,14 +79,14 @@ public CompletionStage<Long> generate(ReactiveConnectionSupplier session, Object
7979
result.complete( next(id) );
8080
}
8181
// send waiting streams back to try again
82-
list.forEach( completion -> generate(session, entity)
83-
.thenAccept(completion::complete) );
82+
list.forEach(Runnable::run);
8483
// } );
8584
} );
8685
}
8786
else {
8887
// wait for the concurrent fetch to complete
89-
queue.add(result);
88+
// note that we carefully capture the right session,entity here!
89+
queue.add( () -> generate(session, entity).thenAccept(result::complete) );
9090
}
9191
return result;
9292
}

0 commit comments

Comments
 (0)