io.trane.future.Future.onFailure()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(2.4k)|赞(0)|评价(0)|浏览(152)

本文整理了Java中io.trane.future.Future.onFailure()方法的一些代码示例,展示了Future.onFailure()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Future.onFailure()方法的具体详情如下:
包路径:io.trane.future.Future
类名称:Future
方法名:onFailure

Future.onFailure介绍

[英]Executes the Consumer if this future completes with an exception.
[中]如果此future在异常情况下完成,则执行使用者。

代码示例

代码示例来源:origin: traneio/future

@Override
 final Future<T> apply(final Future<T> result) {
  return result.onFailure(c);
 }
}

代码示例来源:origin: traneio/ndbc

protected final <T> CompletionStage<T> conv(final Future<T> fut) {
 final CompletableFuture<T> cf = new CompletableFuture<>();
 fut.onSuccess(cf::complete).onFailure(cf::completeExceptionally);
 return cf;
}

代码示例来源:origin: traneio/ndbc

private final <T> InterruptHandler handler(final Promise<T> p) {
 return ex -> {
  final DataSource<PreparedStatement, Row> ds = dataSourceSupplier.get();
  ds.execute("KILL QUERY " + connectionId)
    .onFailure(e -> log.warn("Can't cancel request. Reason: " + e))
    .ensure(() -> ds.close());
 };
}

代码示例来源:origin: traneio/ndbc

private final <T> InterruptHandler handler(final Promise<T> p) {
 return ex -> backendKeyData.ifPresent(data -> channelSupplier.get()
   .flatMap(channel -> Exchange
     .send(marshallers.cancelRequest, new CancelRequest(data.processId, data.secretKey))
     .then(Exchange.CLOSE).run(channel))
   .onFailure(e -> log.warn("Can't cancel request. Reason: " + e)));
}

代码示例来源:origin: traneio/ndbc

protected final <T> Future<T> convert(final io.trane.future.Future<T> future) {
 final Promise<T> promise = Promise$.MODULE$.apply();
 future.onSuccess(promise::success).onFailure(promise::failure);
 return promise.future();
}

代码示例来源:origin: traneio/ndbc

protected final <T> Future<T> convert(final io.trane.future.Future<T> future) {
 final Promise<T> promise = Promise$.MODULE$.apply();
 future.onSuccess(promise::success).onFailure(promise::failure);
 return promise.future();
}

代码示例来源:origin: traneio/ndbc

protected final <T> Future<T> convert(final io.trane.future.Future<T> future) {
 final Promise<T> promise = Promise.apply();
 promise.setInterruptHandler(new PartialFunction<Throwable, BoxedUnit>() {
  @Override
  public BoxedUnit apply(final Throwable v1) {
   future.raise(v1);
   return BoxedUnit.UNIT;
  }
  @Override
  public boolean isDefinedAt(final Throwable x) {
   return true;
  }
 });
 future.onSuccess(promise::setValue).onFailure(promise::setException);
 return promise;
}

相关文章