Merge "Stop using deprecated ImmutableMap.Builder#build() method"
diff --git a/java/com/google/gerrit/plugins/codeowners/acceptance/AbstractCodeOwnersTest.java b/java/com/google/gerrit/plugins/codeowners/acceptance/AbstractCodeOwnersTest.java
index 1309568..32c82a1 100644
--- a/java/com/google/gerrit/plugins/codeowners/acceptance/AbstractCodeOwnersTest.java
+++ b/java/com/google/gerrit/plugins/codeowners/acceptance/AbstractCodeOwnersTest.java
@@ -191,7 +191,7 @@
.message("Configure code owner backend")
.add("code-owners.config", codeOwnersConfig.toText()));
}
- projectCache.evict(project);
+ projectCache.evictAndReindex(project);
}
protected void createOwnersOverrideLabel() throws RestApiException {
diff --git a/java/com/google/gerrit/plugins/codeowners/backend/config/BackendConfig.java b/java/com/google/gerrit/plugins/codeowners/backend/config/BackendConfig.java
index dbe3744..2077d64 100644
--- a/java/com/google/gerrit/plugins/codeowners/backend/config/BackendConfig.java
+++ b/java/com/google/gerrit/plugins/codeowners/backend/config/BackendConfig.java
@@ -33,8 +33,6 @@
import com.google.gerrit.server.git.validators.ValidationMessage;
import com.google.inject.Inject;
import com.google.inject.Singleton;
-import java.util.ArrayList;
-import java.util.List;
import java.util.Optional;
import org.eclipse.jgit.lib.Config;
@@ -110,7 +108,7 @@
requireNonNull(fileName, "fileName");
requireNonNull(projectLevelConfig, "projectLevelConfig");
- List<CommitValidationMessage> validationMessages = new ArrayList<>();
+ ImmutableList.Builder<CommitValidationMessage> validationMessages = ImmutableList.builder();
String backendName = projectLevelConfig.getString(SECTION_CODE_OWNERS, null, KEY_BACKEND);
if (backendName != null) {
@@ -166,7 +164,7 @@
}
}
- return ImmutableList.copyOf(validationMessages);
+ return validationMessages.build();
}
/**
diff --git a/java/com/google/gerrit/plugins/codeowners/backend/config/CodeOwnersPluginConfigValidator.java b/java/com/google/gerrit/plugins/codeowners/backend/config/CodeOwnersPluginConfigValidator.java
index 2353a31..651ce61 100644
--- a/java/com/google/gerrit/plugins/codeowners/backend/config/CodeOwnersPluginConfigValidator.java
+++ b/java/com/google/gerrit/plugins/codeowners/backend/config/CodeOwnersPluginConfigValidator.java
@@ -33,8 +33,6 @@
import com.google.inject.Inject;
import com.google.inject.Singleton;
import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
import org.eclipse.jgit.errors.ConfigInvalidException;
import org.eclipse.jgit.lib.Config;
import org.eclipse.jgit.lib.ObjectId;
@@ -166,7 +164,7 @@
*/
public ImmutableList<CommitValidationMessage> validateConfig(
ProjectState projectState, String fileName, Config cfg) {
- List<CommitValidationMessage> validationMessages = new ArrayList<>();
+ ImmutableList.Builder<CommitValidationMessage> validationMessages = ImmutableList.builder();
validationMessages.addAll(backendConfig.validateProjectLevelConfig(fileName, cfg));
validationMessages.addAll(generalConfig.validateProjectLevelConfig(fileName, cfg));
validationMessages.addAll(statusConfig.validateProjectLevelConfig(fileName, cfg));
@@ -174,7 +172,7 @@
requiredApprovalConfig.validateProjectLevelConfig(projectState, fileName, cfg));
validationMessages.addAll(
overrideApprovalConfig.validateProjectLevelConfig(projectState, fileName, cfg));
- return ImmutableList.copyOf(validationMessages);
+ return validationMessages.build();
}
/**
diff --git a/java/com/google/gerrit/plugins/codeowners/backend/config/GeneralConfig.java b/java/com/google/gerrit/plugins/codeowners/backend/config/GeneralConfig.java
index 7e71f09..5540f0a 100644
--- a/java/com/google/gerrit/plugins/codeowners/backend/config/GeneralConfig.java
+++ b/java/com/google/gerrit/plugins/codeowners/backend/config/GeneralConfig.java
@@ -38,9 +38,7 @@
import com.google.gerrit.server.project.RefPatternMatcher;
import com.google.inject.Inject;
import com.google.inject.Singleton;
-import java.util.ArrayList;
import java.util.Arrays;
-import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.regex.PatternSyntaxException;
@@ -113,7 +111,7 @@
requireNonNull(fileName, "fileName");
requireNonNull(projectLevelConfig, "projectLevelConfig");
- List<CommitValidationMessage> validationMessages = new ArrayList<>();
+ ImmutableList.Builder<CommitValidationMessage> validationMessages = ImmutableList.builder();
try {
projectLevelConfig.getEnum(
@@ -175,7 +173,7 @@
ValidationMessage.Type.ERROR));
}
- return ImmutableList.copyOf(validationMessages);
+ return validationMessages.build();
}
/**
diff --git a/java/com/google/gerrit/plugins/codeowners/backend/config/StatusConfig.java b/java/com/google/gerrit/plugins/codeowners/backend/config/StatusConfig.java
index c3d4dee..d75a3fa 100644
--- a/java/com/google/gerrit/plugins/codeowners/backend/config/StatusConfig.java
+++ b/java/com/google/gerrit/plugins/codeowners/backend/config/StatusConfig.java
@@ -31,8 +31,6 @@
import com.google.gerrit.server.project.RefPatternMatcher;
import com.google.inject.Inject;
import com.google.inject.Singleton;
-import java.util.ArrayList;
-import java.util.List;
import java.util.regex.PatternSyntaxException;
import org.eclipse.jgit.lib.Config;
@@ -81,7 +79,7 @@
requireNonNull(fileName, "fileName");
requireNonNull(projectLevelConfig, "projectLevelConfig");
- List<CommitValidationMessage> validationMessages = new ArrayList<>();
+ ImmutableList.Builder<CommitValidationMessage> validationMessages = ImmutableList.builder();
try {
projectLevelConfig.getBoolean(SECTION_CODE_OWNERS, null, KEY_DISABLED, false);
@@ -117,7 +115,7 @@
}
}
- return ImmutableList.copyOf(validationMessages);
+ return validationMessages.build();
}
/**
diff --git a/java/com/google/gerrit/plugins/codeowners/backend/findowners/FindOwnersCodeOwnerConfigParser.java b/java/com/google/gerrit/plugins/codeowners/backend/findowners/FindOwnersCodeOwnerConfigParser.java
index 01ab9b9..5f35099 100644
--- a/java/com/google/gerrit/plugins/codeowners/backend/findowners/FindOwnersCodeOwnerConfigParser.java
+++ b/java/com/google/gerrit/plugins/codeowners/backend/findowners/FindOwnersCodeOwnerConfigParser.java
@@ -191,7 +191,7 @@
private static final Pattern PAT_PER_FILE =
Pattern.compile(BOL + "per-file[\\s]+([^=#]+)=[\\s]*([^#]+)" + EOL);
- private List<ValidationError> validationErrors;
+ private ImmutableList.Builder<ValidationError> validationErrors;
CodeOwnerConfig parse(
ObjectId revision, CodeOwnerConfig.Key codeOwnerConfigKey, String codeOwnerConfigAsString) {
@@ -264,12 +264,12 @@
new String[] {
removeExtraSpaces(perFileMatcher.group(1)), removeExtraSpaces(perFileMatcher.group(2))
};
- String[] dirGlobs = splitGlobs(globsAndOwners[0]);
+ ImmutableSet<String> dirGlobs = splitGlobs(globsAndOwners[0]);
String directive = globsAndOwners[1];
if (directive.equals(TOK_SET_NOPARENT)) {
return CodeOwnerSet.builder()
.setIgnoreGlobalAndParentCodeOwners()
- .setPathExpressions(ImmutableSet.copyOf(dirGlobs))
+ .setPathExpressions(dirGlobs)
.build();
}
@@ -277,7 +277,7 @@
if ((codeOwnerConfigReference = parseInclude(directive)) != null) {
return CodeOwnerSet.builder()
.addImport(codeOwnerConfigReference)
- .setPathExpressions(ImmutableSet.copyOf(dirGlobs))
+ .setPathExpressions(dirGlobs)
.build();
}
@@ -296,7 +296,7 @@
CodeOwnerSet.Builder codeOwnerSet =
CodeOwnerSet.builder()
- .setPathExpressions(ImmutableSet.copyOf(dirGlobs))
+ .setPathExpressions(dirGlobs)
.setCodeOwners(
ownerEmails.stream().map(CodeOwnerReference::create).collect(toImmutableSet()));
ownerEmails.stream()
@@ -320,8 +320,8 @@
* @return the globs as array
*/
@VisibleForTesting
- static String[] splitGlobs(String commaSeparatedGlobs) {
- ArrayList<String> globList = new ArrayList<>();
+ static ImmutableSet<String> splitGlobs(String commaSeparatedGlobs) {
+ ImmutableSet.Builder<String> globList = ImmutableSet.builder();
StringBuilder nextGlob = new StringBuilder();
int curlyBracesIndentionLevel = 0;
int squareBracesIndentionLevel = 0;
@@ -354,7 +354,7 @@
if (nextGlob.length() > 0) {
globList.add(nextGlob.toString());
}
- return globList.toArray(new String[globList.size()]);
+ return globList.build();
}
private static boolean isComment(String line) {
@@ -433,7 +433,7 @@
*/
public ImmutableList<ValidationError> getValidationErrors() {
if (validationErrors != null) {
- return ImmutableList.copyOf(validationErrors);
+ return validationErrors.build();
}
return ImmutableList.of();
}
@@ -441,7 +441,7 @@
@Override
public void error(ValidationError error) {
if (validationErrors == null) {
- validationErrors = new ArrayList<>(4);
+ validationErrors = ImmutableList.builder();
}
validationErrors.add(error);
}
diff --git a/java/com/google/gerrit/plugins/codeowners/restapi/PutCodeOwnerProjectConfig.java b/java/com/google/gerrit/plugins/codeowners/restapi/PutCodeOwnerProjectConfig.java
index 96b467e..4fe0574 100644
--- a/java/com/google/gerrit/plugins/codeowners/restapi/PutCodeOwnerProjectConfig.java
+++ b/java/com/google/gerrit/plugins/codeowners/restapi/PutCodeOwnerProjectConfig.java
@@ -264,7 +264,7 @@
validateConfig(projectResource.getProjectState(), codeOwnersConfig);
codeOwnersProjectConfigFile.commit(metaDataUpdate);
- projectCache.evict(projectResource.getNameKey());
+ projectCache.evictAndReindex(projectResource.getNameKey());
}
CodeOwnerProjectConfigInfo updatedCodeOwnerProjectConfigInfo =
diff --git a/javatests/com/google/gerrit/plugins/codeowners/backend/config/CodeOwnersPluginConfigTest.java b/javatests/com/google/gerrit/plugins/codeowners/backend/config/CodeOwnersPluginConfigTest.java
index 9ca0339..c972af9 100644
--- a/javatests/com/google/gerrit/plugins/codeowners/backend/config/CodeOwnersPluginConfigTest.java
+++ b/javatests/com/google/gerrit/plugins/codeowners/backend/config/CodeOwnersPluginConfigTest.java
@@ -471,6 +471,6 @@
.message("Configure code owner backend")
.add("code-owners.config", String.format("[%s \"%s\"]", SECTION, subsection)));
}
- projectCache.evict(project);
+ projectCache.evictAndReindex(project);
}
}
diff --git a/javatests/com/google/gerrit/plugins/codeowners/backend/findowners/FindOwnersCodeOwnerConfigParserTest.java b/javatests/com/google/gerrit/plugins/codeowners/backend/findowners/FindOwnersCodeOwnerConfigParserTest.java
index ae42bcd..260e635 100644
--- a/javatests/com/google/gerrit/plugins/codeowners/backend/findowners/FindOwnersCodeOwnerConfigParserTest.java
+++ b/javatests/com/google/gerrit/plugins/codeowners/backend/findowners/FindOwnersCodeOwnerConfigParserTest.java
@@ -924,7 +924,6 @@
private static void assertSplitGlobs(String commaSeparatedGlobs, String... expectedGlobs) {
assertThat(FindOwnersCodeOwnerConfigParser.Parser.splitGlobs(commaSeparatedGlobs))
- .asList()
.containsExactlyElementsIn(expectedGlobs);
}
}