1

我最近更新到 Eclipse Neon 并且我现有的代码停止编译。似乎编译器无法进行类型推断,并使我进行不必要的显式转换。我有这个示例代码:

public class ProductManager {

    //Mocked: originaly a Bean
    com.google.common.util.concurrent.ListeningExecutorService executor;

    public Stream<Result<Product, ItineraryDTO>> getItineraries(Set<Product> productsSet) {
        // Asynchronously get itinerary for every flight
        Stream<ListenableFuture<Result<Product, ItineraryDTO>>> futures =
            productsSet.stream().map(Result.asyncCall(product ->
                    this.executor.submit(() -> this.getItinerary(product)
                )));

        // Wait and get results for every submitted task
        Stream<Result<Product, ItineraryDTO>> results = Result.waitAndGet(futures);
        return results;
    }

    private ItineraryDTO getItinerary(Product flight) {
        // Mocked: originaly get itinerary from a REST service
        return new ItineraryDTO();
    }
    }

asyncCall方法具有以下签名:

public static <T, U> Function<T, ListenableFuture<Result<T, U>>> asyncCall(
            Function<T, ListenableFuture<U>> asyncMethod);

Eclipse 建议我必须转换结果流。这是一个 Eclipse 错误还是我做错了什么?

4

1 回答 1

1

这是Eclipse Mars (4.5) 中引入的一个错误(请参阅错误 496942 评论 8以获取重现示例)。同时它已被修复(截至 Eclipse Oxygen (4.7) 的里程碑 1)。可以使用此集成构建测试修复程序。

于 2016-07-02T13:14:38.450 回答