Tag: 未来可完成

从Completable Future中的lambda投掷时未报告的exception

当我编译下面的代码时,我收到以下错误: /home/prakashs/composite_indexes/src/main/java/com/spakai/composite/TwoKeyLookup.java:22: error: unreported exception NoMatchException; must be caught or declared to be thrown CompletableFuture<Set> result = calling.thenCombine(called, (s1, s2) -> findCommonMatch(s1, s2)); 代码: public CompletableFuture<Set> lookup(K callingNumber, K calledNumber) throws NoMatchException { CompletableFuture<Set> calling = callingNumberIndex.exactMatch(callingNumber); CompletableFuture<Set> called = calledNumberIndex.exactMatch(calledNumber); CompletableFuture<Set> result = calling.thenCombine(called, (s1, s2) -> findCommonMatch(s1, s2)); return result; } public Set […]