Created
November 10, 2015 22:32
-
-
Save tifletcher/c78d4b258919a5186940 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final List<Future<UserProfile>> futures = userIds.stream().distinct().filter(Objects::nonNull) | |
.map(id -> new GetUserProfileCommand(registry, authToken, id, roleMap).queue()) | |
.collect(Collectors.toList()); | |
return futures.stream().parallel() | |
.map(f -> { | |
try { | |
return f.get(); | |
} catch (InterruptedException | ExecutionException e) { | |
return null; | |
} | |
}) | |
.filter(Objects::nonNull) | |
.collect(Collectors.toConcurrentMap(UserProfile::getUserId, profile -> profile)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment