Skip to content

Commit

Permalink
Remove usage of Handler/AsyncResult idiom.
Browse files Browse the repository at this point in the history
  • Loading branch information
vietj committed Sep 12, 2024
1 parent e31ec56 commit 3928ac8
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 100 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,14 @@ public void setUp() throws Exception {
}

@Override
protected void clusteredVertx(VertxOptions options, ClusterManager clusterManager, Handler<AsyncResult<Vertx>> handler) {
CountDownLatch latch = new CountDownLatch(1);
Promise<Vertx> promise = Promise.promise();
promise.future().onComplete(ar -> {
handler.handle(ar);
latch.countDown();
});
super.clusteredVertx(options, clusterManager, promise);
protected Future<Vertx> clusteredVertx(VertxOptions options, ClusterManager clusterManager) {
Future<Vertx> ret = super.clusteredVertx(options, clusterManager);
try {
assertTrue(latch.await(2, TimeUnit.MINUTES));
} catch (InterruptedException e) {
ret.await(2, TimeUnit.MINUTES);
} catch (Exception e) {
fail(e.getMessage());
}
return ret;
}

@Override
Expand Down
15 changes: 5 additions & 10 deletions vertx-infinispan/src/test/java/io/vertx/core/InfinispanHATest.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,14 @@ public void setUp() throws Exception {
}

@Override
protected void clusteredVertx(VertxOptions options, ClusterManager clusterManager, Handler<AsyncResult<Vertx>> handler) {
CountDownLatch latch = new CountDownLatch(1);
Promise<Vertx> promise = Promise.promise();
promise.future().onComplete(ar -> {
handler.handle(ar);
latch.countDown();
});
super.clusteredVertx(options, clusterManager, promise);
protected Future<Vertx> clusteredVertx(VertxOptions options, ClusterManager clusterManager) {
Future<Vertx> ret = super.clusteredVertx(options, clusterManager);
try {
assertTrue(latch.await(2, TimeUnit.MINUTES));
} catch (InterruptedException e) {
ret.await(2, TimeUnit.MINUTES);
} catch (Exception e) {
fail(e.getMessage());
}
return ret;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,14 @@ public void setUp() throws Exception {
}

@Override
protected void clusteredVertx(VertxOptions options, ClusterManager clusterManager, Handler<AsyncResult<Vertx>> handler) {
CountDownLatch latch = new CountDownLatch(1);
Promise<Vertx> promise = Promise.promise();
promise.future().onComplete(ar -> {
handler.handle(ar);
latch.countDown();
});
super.clusteredVertx(options, clusterManager, promise);
protected Future<Vertx> clusteredVertx(VertxOptions options, ClusterManager clusterManager) {
Future<Vertx> ret = super.clusteredVertx(options, clusterManager);
try {
assertTrue(latch.await(2, TimeUnit.MINUTES));
} catch (InterruptedException e) {
ret.await(2, TimeUnit.MINUTES);
} catch (Exception e) {
fail(e.getMessage());
}
return ret;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,14 @@ public void setUp() throws Exception {
}

@Override
protected void clusteredVertx(VertxOptions options, ClusterManager clusterManager, Handler<AsyncResult<Vertx>> handler) {
CountDownLatch latch = new CountDownLatch(1);
Promise<Vertx> promise = Promise.promise();
promise.future().onComplete(ar -> {
handler.handle(ar);
latch.countDown();
});
super.clusteredVertx(options, clusterManager, promise);
protected Future<Vertx> clusteredVertx(VertxOptions options, ClusterManager clusterManager) {
Future<Vertx> ret = super.clusteredVertx(options, clusterManager);
try {
assertTrue(latch.await(2, TimeUnit.MINUTES));
} catch (InterruptedException e) {
ret.await(2, TimeUnit.MINUTES);
} catch (Exception e) {
fail(e.getMessage());
}
return ret;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,14 @@ public void setUp() throws Exception {
}

@Override
protected void clusteredVertx(VertxOptions options, ClusterManager clusterManager, Handler<AsyncResult<Vertx>> handler) {
CountDownLatch latch = new CountDownLatch(1);
Promise<Vertx> promise = Promise.promise();
promise.future().onComplete(ar -> {
handler.handle(ar);
latch.countDown();
});
super.clusteredVertx(options, clusterManager, promise);
protected Future<Vertx> clusteredVertx(VertxOptions options, ClusterManager clusterManager) {
Future<Vertx> ret = super.clusteredVertx(options, clusterManager);
try {
assertTrue(latch.await(2, TimeUnit.MINUTES));
} catch (InterruptedException e) {
ret.await(2, TimeUnit.MINUTES);
} catch (Exception e) {
fail(e.getMessage());
}
return ret;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,14 @@ public void setUp() throws Exception {
}

@Override
protected void clusteredVertx(VertxOptions options, ClusterManager clusterManager, Handler<AsyncResult<Vertx>> handler) {
CountDownLatch latch = new CountDownLatch(1);
Promise<Vertx> promise = Promise.promise();
promise.future().onComplete(ar -> {
handler.handle(ar);
latch.countDown();
});
super.clusteredVertx(options, clusterManager, promise);
protected Future<Vertx> clusteredVertx(VertxOptions options, ClusterManager clusterManager) {
Future<Vertx> ret = super.clusteredVertx(options, clusterManager);
try {
assertTrue(latch.await(2, TimeUnit.MINUTES));
} catch (InterruptedException e) {
ret.await(2, TimeUnit.MINUTES);
} catch (Exception e) {
fail(e.getMessage());
}
return ret;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,14 @@ public void setUp() throws Exception {
}

@Override
protected void clusteredVertx(VertxOptions options, ClusterManager clusterManager, Handler<AsyncResult<Vertx>> handler) {
CountDownLatch latch = new CountDownLatch(1);
Promise<Vertx> promise = Promise.promise();
promise.future().onComplete(ar -> {
handler.handle(ar);
latch.countDown();
});
super.clusteredVertx(options, clusterManager, promise);
protected Future<Vertx> clusteredVertx(VertxOptions options, ClusterManager clusterManager) {
Future<Vertx> ret = super.clusteredVertx(options, clusterManager);
try {
assertTrue(latch.await(2, TimeUnit.MINUTES));
} catch (InterruptedException e) {
ret.await(2, TimeUnit.MINUTES);
} catch (Exception e) {
fail(e.getMessage());
}
return ret;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,14 @@ public void setUp() throws Exception {
}

@Override
protected void clusteredVertx(VertxOptions options, ClusterManager clusterManager, Handler<AsyncResult<Vertx>> handler) {
CountDownLatch latch = new CountDownLatch(1);
Promise<Vertx> promise = Promise.promise();
promise.future().onComplete(ar -> {
handler.handle(ar);
latch.countDown();
});
super.clusteredVertx(options, clusterManager, promise);
protected Future<Vertx> clusteredVertx(VertxOptions options, ClusterManager clusterManager) {
Future<Vertx> ret = super.clusteredVertx(options, clusterManager);
try {
assertTrue(latch.await(2, TimeUnit.MINUTES));
} catch (InterruptedException e) {
ret.await(2, TimeUnit.MINUTES);
} catch (Exception e) {
fail(e.getMessage());
}
return ret;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,14 @@ public void setUp() throws Exception {
}

@Override
protected void clusteredVertx(VertxOptions options, ClusterManager clusterManager, Handler<AsyncResult<Vertx>> handler) {
CountDownLatch latch = new CountDownLatch(1);
Promise<Vertx> promise = Promise.promise();
promise.future().onComplete(ar -> {
handler.handle(ar);
latch.countDown();
});
super.clusteredVertx(options, clusterManager, promise);
protected Future<Vertx> clusteredVertx(VertxOptions options, ClusterManager clusterManager) {
Future<Vertx> ret = super.clusteredVertx(options, clusterManager);
try {
assertTrue(latch.await(2, TimeUnit.MINUTES));
} catch (InterruptedException e) {
ret.await(2, TimeUnit.MINUTES);
} catch (Exception e) {
fail(e.getMessage());
}
return ret;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,14 @@ public void setUp() throws Exception {
}

@Override
protected void clusteredVertx(VertxOptions options, ClusterManager clusterManager, Handler<AsyncResult<Vertx>> handler) {
CountDownLatch latch = new CountDownLatch(1);
Promise<Vertx> promise = Promise.promise();
promise.future().onComplete(ar -> {
handler.handle(ar);
latch.countDown();
});
super.clusteredVertx(options, clusterManager, promise);
protected Future<Vertx> clusteredVertx(VertxOptions options, ClusterManager clusterManager) {
Future<Vertx> ret = super.clusteredVertx(options, clusterManager);
try {
assertTrue(latch.await(2, TimeUnit.MINUTES));
} catch (InterruptedException e) {
ret.await(2, TimeUnit.MINUTES);
} catch (Exception e) {
fail(e.getMessage());
}
return ret;
}

@Override
Expand Down

0 comments on commit 3928ac8

Please sign in to comment.