Skip to content

Commit d1a5928

Browse files
authored
Capture RowStreamImpl endHandler in a synchronized block (#1581)
* Capture RowStreamImpl endHandler in a synchronized block Follows-up on #1577 The endHandler was no longer captured safely after changes in the previous PR. Signed-off-by: Thomas Segismont <[email protected]> * RowStream handler should be invoked out the synchronized block It's safer not to hold a lock on the stream instance while invoking user code. Signed-off-by: Thomas Segismont <[email protected]> --------- Signed-off-by: Thomas Segismont <[email protected]>
1 parent 95b58c8 commit d1a5928

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

vertx-sql-client/src/main/java/io/vertx/sqlclient/impl/RowStreamImpl.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,13 +174,13 @@ private void checkPending() {
174174
emitting = true;
175175
}
176176
while (true) {
177+
Handler handler;
178+
Object event;
177179
synchronized (RowStreamImpl.this) {
178180
if (demand == 0L) {
179181
emitting = false;
180182
break;
181183
}
182-
Handler handler;
183-
Object event;
184184
if (result != null) {
185185
handler = rowHandler;
186186
event = result.next();
@@ -203,8 +203,9 @@ private void checkPending() {
203203
break;
204204
} else {
205205
cursor.close();
206+
Handler<Void> eh = endHandler;
206207
handler = v -> {
207-
endHandler.handle(null);
208+
eh.handle(null);
208209
synchronized (RowStreamImpl.this) {
209210
cursor = null;
210211
}

0 commit comments

Comments
 (0)