CheckerConfig: Don't reload config file on save
We already have the loaded config in memory, there is no need to load it
again.
Signed-off-by: Edwin Kempin <ekempin@google.com>
Change-Id: I963de9701871a8febc16e7845ba98d0354ac5694
diff --git a/java/com/google/gerrit/plugins/checks/db/CheckerConfig.java b/java/com/google/gerrit/plugins/checks/db/CheckerConfig.java
index f601b86..3661f23 100644
--- a/java/com/google/gerrit/plugins/checks/db/CheckerConfig.java
+++ b/java/com/google/gerrit/plugins/checks/db/CheckerConfig.java
@@ -334,8 +334,8 @@
return createBuilderFrom(config, created, commitTimestamp);
}
- private Config updateCheckerProperties() throws IOException, ConfigInvalidException {
- Config config = readConfig(CHECKER_CONFIG_FILE);
+ private Config updateCheckerProperties() throws IOException {
+ Config config = loadedConfig.orElseGet(Config::new);
checkerCreation.ifPresent(
checkerCreation ->
Arrays.stream(CheckerConfigEntry.values())
@@ -345,6 +345,7 @@
Arrays.stream(CheckerConfigEntry.values())
.forEach(configEntry -> configEntry.updateConfigValue(config, checkerUpdate)));
saveConfig(CHECKER_CONFIG_FILE, config);
+ loadedConfig = Optional.of(config);
return config;
}