diff options
author | Patrick Hiesel <hiesel@google.com> | 2023-05-02 13:38:38 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2023-05-02 13:38:38 +0000 |
commit | b0f6f762bbb8fec35a2230656060155e9a7059ff (patch) | |
tree | f16838f6bd0fbb4915137bcf41e7f8bcafcfe81a | |
parent | cf407cb99f3fe9681286df06b2c23759e023948c (diff) | |
parent | 76b979248d8681ddd9e4d63e4e4f37ecb2dc26c5 (diff) |
Merge "ProjectState: simplify the 'getPluginConfig' method" into stable-3.5
-rw-r--r-- | java/com/google/gerrit/server/project/ProjectState.java | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/java/com/google/gerrit/server/project/ProjectState.java b/java/com/google/gerrit/server/project/ProjectState.java index 6352f669f7..b350f3c7e0 100644 --- a/java/com/google/gerrit/server/project/ProjectState.java +++ b/java/com/google/gerrit/server/project/ProjectState.java @@ -475,19 +475,19 @@ public class ProjectState { * {@code PluginConfig#withInheritance(ProjectState.Factory)} */ public PluginConfig getPluginConfig(String pluginName) { - if (getConfig().getPluginConfigs().containsKey(pluginName)) { - Config config = new Config(); + Config config = new Config(); + String cachedPluginConfig = getConfig().getPluginConfigs().get(pluginName); + if (cachedPluginConfig != null) { try { - config.fromText(getConfig().getPluginConfigs().get(pluginName)); + config.fromText(cachedPluginConfig); } catch (ConfigInvalidException e) { // This is OK to propagate as IllegalStateException because it's a programmer error. // The config was converted to a String using Config#toText. So #fromText must not // throw a ConfigInvalidException throw new IllegalStateException("invalid plugin config for " + pluginName, e); } - return PluginConfig.create(pluginName, config, getConfig()); } - return PluginConfig.create(pluginName, new Config(), getConfig()); + return PluginConfig.create(pluginName, config, getConfig()); } public Optional<BranchOrderSection> getBranchOrderSection() { |