proxyToAdd.stream() .map(proxy -> Try.of(() -> pool.register(proxy, timeService.getCurrentDate()))) .peek(t -> t.onFailure(e -> logger.error("Error while registering proxy in pool", e))) .filter(Try::isSuccess) .map(Try::get) .collect(Collectors.toList()); proxyToAdd.stream() .map(proxy -> { Try.of(() -> pool.register(proxy, timeService.getCurrentDate())) .onFailure(e -> logger.error("Error while registering proxy in pool", e)) }) .filter(Try::isSuccess) .map(Try::get) .collect(Collectors.toList());