List of usage examples for io.vertx.core AsyncResult mapEmpty
default <V> AsyncResult<V> mapEmpty()
This is a convenience for asyncResult.map((T) null) or asyncResult.map((Void) null) .
When this async result succeeds, null will succeeed the async result returned by this method call.
When this async result fails, the failure will be propagated to the returned async result.
From source file:io.reactiverse.pgclient.impl.pubsub.PgSubscriberImpl.java
License:Apache License
private synchronized void handleConnectResult(Handler<AsyncResult<Void>> completionHandler, AsyncResult<PgConnection> ar1) { connecting = false;//from ww w . j av a 2 s . com if (ar1.succeeded()) { conn = ar1.result(); conn.notificationHandler(PgSubscriberImpl.this::handleNotification); conn.closeHandler(PgSubscriberImpl.this::handleClose); if (channels.size() > 0) { List<Handler<Void>> handlers = channels.values().stream().flatMap(channel -> channel.subs.stream()) .map(sub -> sub.subscribeHandler).filter(Objects::nonNull).collect(Collectors.toList()); String sql = channels.values().stream().map(channel -> { channel.subscribed = true; return channel.quotedName; }).collect(Collectors.joining(";LISTEN ", "LISTEN ", "")); conn.query(sql, ar2 -> { if (ar2.failed()) { log.error("Cannot LISTEN to channels", ar2.cause()); conn.close(); } else { handlers.forEach(vertx::runOnContext); } completionHandler.handle(ar2.mapEmpty()); }); return; } } completionHandler.handle(ar1.mapEmpty()); }