本文整理了Java中scala.concurrent.Future.recover()
方法的一些代码示例,展示了Future.recover()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Future.recover()
方法的具体详情如下:
包路径:scala.concurrent.Future
类名称:Future
方法名:recover
暂无
代码示例来源:origin: org.opendaylight.controller/sal-distributed-datastore
@Override
public Future<Object> apply(final CanCommit input) {
return Patterns.ask(input.getCohort(), input, timeout).recover(EXCEPTION_TO_MESSAGE,
ExecutionContexts.global());
}
}, ExecutionContexts.global());
代码示例来源:origin: org.apache.flink/flink-runtime_2.10
@Override
public <R> Future<R> exceptionallyAsync(final ApplyFunction<Throwable, ? extends R> exceptionallyFunction, Executor executor) {
Preconditions.checkNotNull(scalaFuture);
Preconditions.checkNotNull(exceptionallyFunction);
Preconditions.checkNotNull(executor);
scala.concurrent.Future<R> recoveredFuture = scalaFuture.recover(new Recover<R>() {
@Override
public R recover(Throwable failure) throws Throwable {
return exceptionallyFunction.apply(failure);
}
}, createExecutionContext(executor));
return new FlinkFuture<>(recoveredFuture);
}
代码示例来源:origin: keeps/roda
@Override
public void onReceive(Object message) {
Timeout timeout = new Timeout(5, TimeUnit.SECONDS);
Future<Object> f = ask(masterProxy, message, timeout);
final ExecutionContext ec = getContext().system().dispatcher();
Future<Object> res = f.map(new Mapper<Object, Object>() {
@Override
public Object apply(Object msg) {
if (msg instanceof Master.Ack)
return Ok.getInstance();
else
return super.apply(msg);
}
}, ec).recover(new Recover<Object>() {
@Override
public Object recover(Throwable failure) throws Throwable {
return NotOk.getInstance();
}
}, ec);
pipe(res, ec).to(getSender());
}
内容来源于网络,如有侵权,请联系作者删除!