From 2ac64829407349d696108c9d09c70d7ea2ad266a Mon Sep 17 00:00:00 2001 From: Pierre Date: Tue, 8 Dec 2020 13:01:37 +0100 Subject: remove use of Stream.peek() --- .../server/qualityprofile/BuiltInQProfileInsertImpl.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'server/sonar-webserver-auth/src') diff --git a/server/sonar-webserver-auth/src/main/java/org/sonar/server/qualityprofile/BuiltInQProfileInsertImpl.java b/server/sonar-webserver-auth/src/main/java/org/sonar/server/qualityprofile/BuiltInQProfileInsertImpl.java index 8c3b290b79e..5b368c40f91 100644 --- a/server/sonar-webserver-auth/src/main/java/org/sonar/server/qualityprofile/BuiltInQProfileInsertImpl.java +++ b/server/sonar-webserver-auth/src/main/java/org/sonar/server/qualityprofile/BuiltInQProfileInsertImpl.java @@ -20,6 +20,7 @@ package org.sonar.server.qualityprofile; import com.google.common.base.Splitter; +import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; import java.util.Collections; @@ -156,15 +157,14 @@ public class BuiltInQProfileInsertImpl implements BuiltInQProfileInsert { Map valuesByParamKey = activeRule.getParams() .stream() .collect(MoreCollectors.uniqueIndex(BuiltInQualityProfilesDefinition.OverriddenParam::key, BuiltInQualityProfilesDefinition.OverriddenParam::overriddenValue)); - return ruleRepository.getRuleParams(activeRule.getRuleKey()) + List rules = ruleRepository.getRuleParams(activeRule.getRuleKey()) .stream() - .map(param -> { - String activeRuleValue = valuesByParamKey.get(param.getName()); - return createParamDto(param, activeRuleValue == null ? param.getDefaultValue() : activeRuleValue); - }) + .map(param -> createParamDto(param, Optional.ofNullable(valuesByParamKey.get(param.getName())).orElse(param.getDefaultValue()))) .filter(Objects::nonNull) - .peek(paramDto -> dbClient.activeRuleDao().insertParam(session, activeRuleDto, paramDto)) - .collect(MoreCollectors.toList()); + .collect(Collectors.toList()); + + rules.forEach(paramDto -> dbClient.activeRuleDao().insertParam(session, activeRuleDto, paramDto)); + return rules; } @CheckForNull -- cgit v1.2.3