我一直在玩,CompletableFuture并注意到一件奇怪的事情.
String url = "http://google.com";
CompletableFuture<String> contentsCF = readPageCF(url);
CompletableFuture<List<String>> linksCF = contentsCF.thenApply(_4_CompletableFutures::getLinks);
linksCF.thenAccept(list -> {
assertThat(list, not(empty()));
});
linksCF.get();
Run Code Online (Sandbox Code Playgroud)
如果在我的thenAccept调用中断言失败,则不会传播异常.我尝试了一些更丑陋的东西:
linksCF.thenAccept(list -> {
String a = null;
System.out.println(a.toString());
});
Run Code Online (Sandbox Code Playgroud)
没有任何反应,没有例外传播.我尝试使用类似的方法handle和其他与异常相关的方法CompletableFutures,但是失败了 - 没有按预期传播异常.
当我调试它时CompletableFuture,它确实捕获了这样的异常:
final void internalComplete(T v, Throwable ex) {
if (result == null)
UNSAFE.compareAndSwapObject
(this, RESULT, null,
(ex == null) ? (v == null) ? NIL : v :
new AltResult((ex instanceof CompletionException) ? ex :
new CompletionException(ex))); …Run Code Online (Sandbox Code Playgroud) 在我的PayPal开发人员帐户中,在Applications,My apps下,我创建了一个REST API应用程序.
我不再需要它了,想删除它,但是找不到合适的地方.是不允许删除?