Skip to content

Commit

Permalink
Update to executeBlocking API change
Browse files Browse the repository at this point in the history
  • Loading branch information
vietj committed Jul 19, 2023
1 parent 2fee1c0 commit 487ff45
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ private BlockingServerInterceptor(Vertx vertx, ServerInterceptor interceptor) {
public <ReqT, RespT> ServerCall.Listener<ReqT> interceptCall(ServerCall<ReqT, RespT> serverCall, Metadata metadata,
ServerCallHandler<ReqT, RespT> serverCallHandler) {
AsyncListener<ReqT> asyncListener = new AsyncListener<>();
vertx.<ServerCall.Listener<ReqT>>executeBlocking(blockingCode ->
blockingCode.complete(interceptor.interceptCall(serverCall, metadata, serverCallHandler)),
vertx.executeBlocking(() -> interceptor.interceptCall(serverCall, metadata, serverCallHandler),
false).onComplete(
ar -> {
if (ar.succeeded()) {
Expand Down
14 changes: 5 additions & 9 deletions vertx-grpc/src/main/java/io/vertx/grpc/VertxServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,9 @@ void start(ContextInternal context, Handler<AsyncResult<Void>> completionHandler
group.addWorker(context.nettyEventLoop());
contextLocal.get().add(context);
if (start) {
context.<Void>executeBlocking(v2 -> {
try {
server.start();
v2.complete();
} catch (IOException e) {
v2.fail(e);
}
context.<Void>executeBlocking(() -> {
server.start();
return null;
}).onComplete(completionHandler);
} else {
completionHandler.handle(Future.succeededFuture());
Expand All @@ -136,9 +132,9 @@ void stop(ContextInternal context, Promise<Void> promise) {
contextLocal.get().remove(context);
if (shutdown) {
map.remove(id);
context.<Void>executeBlocking(p -> {
context.<Void>executeBlocking(() -> {
server.shutdown();
p.complete();
return null;
}).onComplete(promise);
} else {
promise.complete();
Expand Down

0 comments on commit 487ff45

Please sign in to comment.