Skip to content

Commit 95b58c8

Browse files
authored
Cursor.close() does not complete if it was already called (#1578)
See #1410 Signed-off-by: Thomas Segismont <[email protected]>
1 parent 1e48ff8 commit 95b58c8

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

vertx-mysql-client/src/test/java/io/vertx/tests/mysqlclient/tck/ProxySQLPreparedQueryTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@ public void testQueryCloseCursor(TestContext ctx) {
4545
super.testQueryCloseCursor(ctx);
4646
}
4747

48+
@Test
49+
@Ignore("Fetch command not supported by ProxySQL")
50+
@Override
51+
public void testQueryCloseCursorTwice(TestContext ctx) {
52+
super.testQueryCloseCursorTwice(ctx);
53+
}
54+
4855
@Test
4956
@Ignore("Fetch command not supported by ProxySQL")
5057
@Override

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ private synchronized void close(Promise<Void> promise) {
110110
result = null;
111111
ps.closeCursor(id, promise);
112112
}
113+
} else {
114+
promise.complete();
113115
}
114116
}
115117
}

vertx-sql-client/src/test/java/io/vertx/tests/sqlclient/tck/PreparedQueryTestBase.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
package io.vertx.tests.sqlclient.tck;
1212

1313
import io.vertx.core.AsyncResult;
14+
import io.vertx.core.Future;
1415
import io.vertx.core.Handler;
1516
import io.vertx.core.Vertx;
1617
import io.vertx.ext.unit.Async;
@@ -318,6 +319,19 @@ public void testQueryCloseCursor(TestContext ctx) {
318319
});
319320
}
320321

322+
@Test
323+
public void testQueryCloseCursorTwice(TestContext ctx) {
324+
Async async = ctx.async();
325+
testCursor(ctx, conn -> {
326+
conn
327+
.prepare("SELECT * FROM immutable")
328+
.onComplete(ctx.asyncAssertSuccess(ps -> {
329+
Cursor cursor = ps.cursor(Tuple.tuple());
330+
Future.all(cursor.close(), cursor.close()).onComplete(ctx.asyncAssertSuccess(v -> async.complete()));
331+
}));
332+
});
333+
}
334+
321335
@Test
322336
public void testQueryStreamCloseCursor(TestContext ctx) {
323337
Async async = ctx.async();

0 commit comments

Comments
 (0)