@@ -313,6 +313,7 @@ public void testWithTransactionImplicitRollback(TestContext ctx) {
313
313
public void testWithPropagatedConnectionTransactionCommit (TestContext ctx ) {
314
314
Async async = ctx .async ();
315
315
Pool pool = createPool ();
316
+ vertx .runOnContext (handler -> {
316
317
pool .withPropagatedTransaction (c ->
317
318
pool .withPropagatedTransaction (conn -> conn .query ("INSERT INTO mutable (id, val) VALUES (1, 'hello-1')" ).execute ().mapEmpty ()).flatMap (v ->
318
319
pool .withPropagatedTransaction (conn -> conn .query ("INSERT INTO mutable (id, val) VALUES (2, 'hello-2')" ).execute ().mapEmpty ())).flatMap (v2 ->
@@ -321,22 +322,27 @@ public void testWithPropagatedConnectionTransactionCommit(TestContext ctx) {
321
322
.query ("SELECT id, val FROM mutable" )
322
323
.execute (ctx .asyncAssertSuccess (rows -> {
323
324
ctx .assertEquals (3 , rows .size ());
325
+ ctx .assertNull (Vertx .currentContext ().getLocal ("propagatable_connection" ));
324
326
async .complete ();
325
327
}))));
328
+ });
326
329
}
327
330
328
331
@ Test
329
332
public void testWithPropagatedConnectionTransactionRollback (TestContext ctx ) {
330
333
Async async = ctx .async ();
331
334
Pool pool = createPool ();
332
335
Throwable failure = new Throwable ();
333
- pool .withPropagatedTransaction (c ->
334
- pool .withPropagatedTransaction (conn -> conn .query ("INSERT INTO mutable (id, val) VALUES (1, 'hello-1')" ).execute ().mapEmpty ().flatMap (v -> Future .failedFuture (failure )))
335
- ).onComplete (ctx .asyncAssertFailure (v -> pool
336
- .query ("SELECT id, val FROM mutable" )
337
- .execute (ctx .asyncAssertSuccess (rows -> {
338
- ctx .assertEquals (0 , rows .size ());
339
- async .complete ();
340
- }))));
336
+ vertx .runOnContext (handler -> {
337
+ pool .withPropagatedTransaction (c ->
338
+ pool .withPropagatedTransaction (conn -> conn .query ("INSERT INTO mutable (id, val) VALUES (1, 'hello-1')" ).execute ().mapEmpty ().flatMap (v -> Future .failedFuture (failure )))
339
+ ).onComplete (ctx .asyncAssertFailure (v -> pool
340
+ .query ("SELECT id, val FROM mutable" )
341
+ .execute (ctx .asyncAssertSuccess (rows -> {
342
+ ctx .assertEquals (0 , rows .size ());
343
+ ctx .assertNull (Vertx .currentContext ().getLocal ("propagatable_connection" ));
344
+ async .complete ();
345
+ }))));
346
+ });
341
347
}
342
348
}
0 commit comments