Skip to content

Commit

Permalink
Stream supply fix
Browse files Browse the repository at this point in the history
  • Loading branch information
VeryExtraordinaryUsername committed Nov 24, 2023
1 parent 2cbf1b5 commit 0a28aaf
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/main/java/org/prebid/server/handler/SetuidHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
import java.util.Optional;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import java.util.stream.Stream;

Expand Down Expand Up @@ -109,16 +110,17 @@ public SetuidHandler(long defaultTimeout,

private static Map<String, UsersyncMethodType> collectMap(BidderCatalog bidderCatalog) {

final Stream<Usersyncer> usersyncers = bidderCatalog.names().stream()
final Supplier<Stream<Usersyncer>> usersyncers = () -> bidderCatalog.names()
.stream()
.filter(bidderCatalog::isActive)
.map(bidderCatalog::usersyncerByName)
.filter(Optional::isPresent)
.map(Optional::get)
.distinct();

validateUsersyncers(usersyncers);
validateUsersyncers(usersyncers.get());

return usersyncers
return usersyncers.get()
.collect(Collectors.toMap(Usersyncer::getCookieFamilyName, SetuidHandler::preferredUserSyncType));
}

Expand All @@ -131,7 +133,6 @@ private static UsersyncMethodType preferredUserSyncType(Usersyncer usersyncer) {
}

private static void validateUsersyncers(Stream<Usersyncer> usersyncers) {

final Stream<String> cookieFamilyNameDuplicates = usersyncers.map(Usersyncer::getCookieFamilyName)
.collect(Collectors.groupingBy(Function.identity(), Collectors.counting()))
.entrySet()
Expand Down

0 comments on commit 0a28aaf

Please sign in to comment.