private static void throwing() {
assertThrows(RuntimeException.class,() -> immediateFuture(null));
assertThrows(
RuntimeException.class,() -> {
immediateFuture(null);
});
assertThrows(
RuntimeException.class,new ThrowingRunnable() {
@Override
public void run() throws Throwable {
immediateFuture(null);
}
});
}
项目:google-cloud-intellij
文件:CloudToolsRule.java
/**
* Wraps the given {@link ThrowingRunnable} in a {@link Runnable} that transforms all {@link
* Throwable throwables} to a {@link RuntimeException}.
*/
private static Runnable wrap(ThrowingRunnable runnable) {
return () -> {
try {
runnable.run();
} catch (Throwable throwable) {
throw new RuntimeException(throwable);
}
};
}
项目:google-cloud-intellij
文件:CloudToolsRule.java
/** Runs the given {@link ThrowingRunnable} as a write action on the main thread. */
private static void writeOnMainThread(ThrowingRunnable runnable) {
ApplicationManager.getApplication()
.invokeAndWait(() -> ApplicationManager.getApplication().runWriteAction(wrap(runnable)));
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。