Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Selectively revert "simplify stream toList" #9688

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;

/**
* A Finder implementation that uses multiple finders to search
Expand All @@ -34,6 +35,6 @@ class CompositeFinder implements Finder {
public List<String> findExcluding(String[] excluding, String endStr) {
return this.finderList.stream()
.flatMap(finder -> finder.findExcluding(excluding, endStr).stream())
.toList();
.collect(Collectors.toList());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ else if (me.getValue() instanceof List) {

List<String> allValues = values.stream()
.map(v -> StringUtil.urlEncode(me.getKey()) + "=" + v)
.toList();
.collect(Collectors.toList());

if (!allValues.isEmpty()) {
if (firstPass) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ public static Stream<Action> lookupDependentActions(Action parentAction) {
List<Action> results = findDependentActions.list();
returnSet.addAll(results);
// Reset list of actions for the next hierarchy level:
actionsAtHierarchyLevel = results.stream().map(a -> a.getId()).toList();
actionsAtHierarchyLevel = results.stream().map(a -> a.getId()).collect(Collectors.toList());
}
while (!actionsAtHierarchyLevel.isEmpty());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
Expand Down Expand Up @@ -412,7 +413,7 @@ public void rejectScheduledActionsMarkPendingServerActionsAsFailed() {
TestUtils.saveAndReload(a1);
TestUtils.saveAndReload(a2);

List<Long> actionIds = Stream.of(a1, a2).map(Action::getId).toList();
List<Long> actionIds = Stream.of(a1, a2).map(Action::getId).collect(Collectors.toList());
ActionFactory.rejectScheduledActions(actionIds, "Test Rejection Reason");

sa1 = HibernateFactory.reload(sa1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public static List<AccessToken> unneededTokens(MinionServer minion, Collection<A
tokensToActivate.stream()
.anyMatch(newToken ->
newToken.getChannels().containsAll(token.getChannels()));
}).toList();
}).collect(Collectors.toList());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;

import javax.persistence.NoResultException;
import javax.persistence.TypedQuery;
Expand Down Expand Up @@ -957,7 +958,7 @@ public static List<SsmChannelDto> findChildChannelsByParentInSSM(User user, long
.stream()
.map(Arrays::asList)
.map(r -> new SsmChannelDto((long)r.get(0), (String)r.get(1), r.get(2) != null))
.toList();
.collect(Collectors.toList());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;

import javax.persistence.CascadeType;
import javax.persistence.Column;
Expand Down Expand Up @@ -228,7 +229,7 @@ public List<ProjectSource> getSources() {
public List<ProjectSource> getActiveSources() {
return sources.stream()
.filter(s -> !ProjectSource.State.DETACHED.equals(s.getState()))
.toList();
.collect(Collectors.toList());
}

/**
Expand Down Expand Up @@ -321,7 +322,7 @@ public List<ContentFilter> getActiveFilters() {
return getProjectFilters().stream()
.filter(f -> f.getState() != ContentProjectFilter.State.DETACHED)
.map(ContentProjectFilter::getFilter)
.toList();
.collect(Collectors.toList());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import javax.persistence.criteria.CriteriaBuilder;
Expand Down Expand Up @@ -248,7 +249,7 @@ public static void removeEnvironment(ContentEnvironment toRemove) {
channels.stream().filter(Channel::isBaseChannel).findAny().ifPresent(bc -> {
List<String> rogueChannels = ChannelFactory.listAllChildrenForChannel(bc).stream()
.filter(b -> !childChannels.contains(b))
.map(Channel::getName).toList();
.map(Channel::getName).collect(Collectors.toList());
if (!rogueChannels.isEmpty()) {
throw new ContentManagementException(LocalizationService.getInstance().getMessage(
"contentmanagement.non_environment_channels_found", rogueChannels));
Expand Down Expand Up @@ -499,7 +500,7 @@ public static List<ClonedChannel> lookupClonesInProject(Channel channel, Content
.setParameter("project", project)
.setParameter("channel", channel)
.stream();
return clones.flatMap(c -> c.asCloned().stream()).toList();
return clones.flatMap(c -> c.asCloned().stream()).collect(Collectors.toList());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public ModulePackagesResponse getPackagesForModules(List<Channel> sources, List<
* @throws RepositoryNotModularException if a source channel is not modular
*/
private static List<String> getMetadataPaths(List<Channel> sources) throws RepositoryNotModularException {
return sources.stream().map(ModulemdApi::getMetadataPath).toList();
return sources.stream().map(ModulemdApi::getMetadataPath).collect(Collectors.toList());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
* Validates a content project instance using a specified list of validators
Expand Down Expand Up @@ -60,6 +61,6 @@ public ContentProjectValidator(ContentProject projectIn, List<ContentValidator>
public List<ContentValidationMessage> validate() {
return validators.stream()
.flatMap(v -> v.validate(project).stream())
.toList();
.collect(Collectors.toList());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public List<ContentValidationMessage> validate(ContentProject project) {
.map(m -> ContentValidationMessage.contentFiltersMessage(
loc.getMessage("contentmanagement.validation.modulenotfound", m.getFullName()),
TYPE_ERROR))
.toList();
.collect(Collectors.toList());
}
else if (e.getCause() instanceof ConflictingStreamsException cause) {
Module module = cause.getModule();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.util.Date;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;

import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
Expand Down Expand Up @@ -156,7 +157,7 @@ public static List<Credentials> listCredentials() {
.createQuery(query)
.stream()
.map(Credentials.class::cast)
.toList();
.collect(Collectors.toList());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
import java.util.Optional;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.stream.Collectors;

/**
* ErrataFactory - the singleton class used to fetch and store
Expand Down Expand Up @@ -105,7 +106,7 @@ public static List<Long> listErrataChannelPackages(Long cid, Long eid) {
DataResult<ErrataPackageFile> dr = executeSelectMode(
"ErrataCache_queries",
"package_associated_to_errata_and_channel", params);
return dr.stream().map(file -> file.getPackageId()).toList();
return dr.stream().map(file -> file.getPackageId()).collect(Collectors.toList());
}


Expand Down Expand Up @@ -541,7 +542,7 @@ public static List<Errata> lookupByCVE(String cve) {
Session session = HibernateFactory.getSession();
return result.stream()
.map(row -> session.load(Errata.class, (Long) row.get("id")))
.toList();
.collect(Collectors.toList());
}

/**
Expand Down Expand Up @@ -751,7 +752,7 @@ public static Optional<ErrataFile> lookupErrataFile(Long errataId, String filena
public static List<Tuple2<Long, Long>> retractedPackages(List<Long> pids, List<Long> sids) {
List<Object[]> results = singleton.listObjectsByNamedQuery("Errata.retractedPackages",
Map.of("pids", pids, "sids", sids));
return results.stream().map(r -> new Tuple2<>((long)r[0], (long)r[1])).toList();
return results.stream().map(r -> new Tuple2<>((long)r[0], (long)r[1])).collect(Collectors.toList());
}

/**
Expand All @@ -769,7 +770,7 @@ public static List<Tuple2<Long, Long>> retractedPackagesByNevra(List<String> nev
}
List<Object[]> results = singleton.listObjectsByNamedQuery("Errata.retractedPackagesByNevra",
Map.of("nevras", nevras, "sids", sids));
return results.stream().map(r -> new Tuple2<>((long)r[0], (long)r[1])).toList();
return results.stream().map(r -> new Tuple2<>((long)r[0], (long)r[1])).collect(Collectors.toList());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ public void testRetractedPackagesByNevra() throws Exception {
p.getPackageName().getName() + "-" +
p.getPackageEvr().toUniversalEvrString() + "." +
p.getPackageArch().getLabel()
).toList(),
).collect(Collectors.toList()),
List.of(testMinionServer.getId())
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ public static List<String> getFormulasByGroup(ServerGroup group) {
List<String> formulas = group.getPillars().stream()
.filter(pillar -> pillar.getCategory().startsWith(PREFIX))
.map(pillar -> pillar.getCategory().substring(PREFIX.length()))
.toList();
.collect(Collectors.toList());

return orderFormulas(formulas);
}
Expand All @@ -292,7 +292,7 @@ public static List<String> getFormulasByMinion(MinionServer minion) {
List<String> formulas = orderFormulas(minion.getPillars().stream()
.filter(pillar -> pillar.getCategory().startsWith(PREFIX))
.map(pillar -> pillar.getCategory().substring(PREFIX.length()))
.toList());
.collect(Collectors.toList()));

return orderFormulas(formulas);
}
Expand Down Expand Up @@ -788,7 +788,7 @@ public static List<EndpointInfo> getEndpointsFromFormulaData(FormulaData formula
proxyEnabled ? exporterConfig.getProxyModuleOrFallback() : null,
proxyPath,
tlsEnabled))
.toList();
.collect(Collectors.toList());
}
else {
return new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
Expand Down Expand Up @@ -295,7 +296,7 @@ private static List<KickstartCommandName> lookupKickstartCommandNames(boolean on
// Filter out the unsupported Commands for the passed in profile
return names.stream()
.filter(cn -> !cn.getName().equals("lilocheck") && !cn.getName().equals("langsupport"))
.toList();
.collect(Collectors.toList());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public static List<ChannelTemplate> lookupChannelTemplateByChannelLabel(String c
.stream()
.sorted((a, b) ->
RPM_VERSION_COMPARATOR.compare(b.getProduct().getVersion(), a.getProduct().getVersion()))
.toList();
.collect(Collectors.toList());
}

/**
Expand All @@ -162,7 +162,7 @@ public static void remove(SUSEProduct product) {
@SuppressWarnings("unchecked")
public static void removeAllExcept(Collection<SUSEProduct> products) {
if (!products.isEmpty()) {
List<Long> ids = products.stream().map(SUSEProduct::getId).toList();
List<Long> ids = products.stream().map(SUSEProduct::getId).collect(Collectors.toList());

List<SUSEProduct> productIds = getSession().createNativeQuery("""
SELECT * from suseProducts
Expand All @@ -186,7 +186,7 @@ WHERE id NOT IN (:ids)
public static List<SUSEProductChannel> lookupSyncedProductChannelsByLabel(String channelLabel) {
return Optional.ofNullable(ChannelFactory.lookupByLabel(channelLabel))
.map(channel -> channel.getSuseProductChannels().stream())
.orElseGet(Stream::empty).toList();
.orElseGet(Stream::empty).collect(Collectors.toList());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
import java.util.List;
import java.util.Random;
import java.util.Set;
import java.util.stream.Collectors;

/**
* Utility methods for creating SUSE related test data.
Expand Down Expand Up @@ -564,7 +565,7 @@ else if (!testDataPath.endsWith("/")) {
inputStreamReader7, new TypeToken<List<SCCProductJson>>() { }.getType());
products.addAll(addProducts);
addRepos.addAll(ContentSyncManager.collectRepos(
ContentSyncManager.flattenProducts(addProducts).toList()));
ContentSyncManager.flattenProducts(addProducts).collect(Collectors.toList())));
}
repositories.addAll(addRepos);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.Stream;

Expand Down Expand Up @@ -55,7 +56,7 @@ public static List<Long> countSaltEvents(int queuesCount) {
.filter(c -> c[0].equals(i))
.map(c -> (Long) c[1])
.findFirst()
.orElse(0L)).boxed().toList();
.orElse(0L)).boxed().collect(Collectors.toList());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public void testPopSaltEvents() {
assertEquals(Arrays.asList(0L, 0L, 0L, 0L), saltEventsCount);

// try to pop a salt event when there are none
List<SaltEvent> popedSaltEvents = SaltEventFactory.popSaltEvents(1, 0).toList();
List<SaltEvent> popedSaltEvents = SaltEventFactory.popSaltEvents(1, 0).collect(Collectors.toList());
assertEquals(0, popedSaltEvents.size());

// create and pop 1 salt event
Expand Down Expand Up @@ -172,7 +172,7 @@ public void testDeleteSaltEvents() {
saltEvents.add(saltEvent3);
assertEquals(Arrays.asList(1L, 1L, 1L, 0L), saltEventsCount);

List<Long> saltEventIds = saltEvents.stream().map(SaltEvent::getId).toList();
List<Long> saltEventIds = saltEvents.stream().map(SaltEvent::getId).collect(Collectors.toList());
deletedEventIds = SaltEventFactory.deleteSaltEvents(saltEventIds);
assertEquals(saltEvents.size(), deletedEventIds.size());
assertTrue(deletedEventIds.stream().allMatch(did -> saltEventIds.stream().anyMatch(id -> id.equals(did))));
Expand Down Expand Up @@ -209,7 +209,7 @@ public void testFixQueueNumbers() {
assertEquals(Arrays.asList(0L, 3L, 1L, 0L, 0L), saltEventsCount);

// pop the events
List<SaltEvent> popedSaltEvents = SaltEventFactory.popSaltEvents(3, 1).toList();
List<SaltEvent> popedSaltEvents = SaltEventFactory.popSaltEvents(3, 1).collect(Collectors.toList());
assertEquals(popedSaltEvents.size(), 3);
popedSaltEvents = SaltEventFactory.popSaltEvents(1, 2).toList();
assertEquals(popedSaltEvents.size(), 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.apache.commons.lang3.builder.HashCodeBuilder;

import java.util.List;
import java.util.stream.Collectors;

import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
Expand Down Expand Up @@ -76,7 +77,7 @@ public GroupRecurringAction(RecurringActionType actionType, boolean active, Serv
@Override
public List<MinionServer> computeMinions() {
return MinionServerUtils.filterSaltMinions(ServerGroupFactory.listServers(group))
.toList();
.collect(Collectors.toList());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.apache.commons.lang3.builder.HashCodeBuilder;

import java.util.List;
import java.util.stream.Collectors;

import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
Expand Down Expand Up @@ -72,7 +73,7 @@ public OrgRecurringAction(RecurringActionType actionType, boolean active, Org or
@Override
public List<MinionServer> computeMinions() {
return MinionServerUtils.filterSaltMinions(ServerFactory.listOrgSystems(organization.getId()))
.toList();
.collect(Collectors.toList());
}

/**
Expand Down
Loading
Loading