Merge "PluginConfigFactory: reload also outdated secure store"
This commit is contained in:
@@ -139,5 +139,15 @@ public class UpgradeFrom2_0_xTest extends InitTestCase {
|
|||||||
public Iterable<EntryKey> list() {
|
public Iterable<EntryKey> list() {
|
||||||
throw new UnsupportedOperationException("not used by tests");
|
throw new UnsupportedOperationException("not used by tests");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isOutdated() {
|
||||||
|
throw new UnsupportedOperationException("not used by tests");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reload() {
|
||||||
|
throw new UnsupportedOperationException("not used by tests");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -101,6 +101,9 @@ public class PluginConfigFactory implements ReloadPluginListener {
|
|||||||
* @return the plugin configuration from the 'gerrit.config' file
|
* @return the plugin configuration from the 'gerrit.config' file
|
||||||
*/
|
*/
|
||||||
public PluginConfig getFromGerritConfig(String pluginName, boolean refresh) {
|
public PluginConfig getFromGerritConfig(String pluginName, boolean refresh) {
|
||||||
|
if (refresh && secureStore.isOutdated()) {
|
||||||
|
secureStore.reload();
|
||||||
|
}
|
||||||
File configFile = site.gerrit_config.toFile();
|
File configFile = site.gerrit_config.toFile();
|
||||||
if (refresh && cfgSnapshot.isModified(configFile)) {
|
if (refresh && cfgSnapshot.isModified(configFile)) {
|
||||||
cfgSnapshot = FileSnapshot.save(configFile);
|
cfgSnapshot = FileSnapshot.save(configFile);
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ package com.google.gerrit.server.securestore;
|
|||||||
import com.google.gerrit.common.FileUtil;
|
import com.google.gerrit.common.FileUtil;
|
||||||
import com.google.gerrit.server.config.SitePaths;
|
import com.google.gerrit.server.config.SitePaths;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
import com.google.inject.ProvisionException;
|
||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -107,6 +108,20 @@ public class DefaultSecureStore extends SecureStore {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isOutdated() {
|
||||||
|
return sec.isOutdated();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reload() {
|
||||||
|
try {
|
||||||
|
sec.load();
|
||||||
|
} catch (IOException | ConfigInvalidException e) {
|
||||||
|
throw new ProvisionException("Couldn't reload secure.config", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void save() {
|
private void save() {
|
||||||
try {
|
try {
|
||||||
saveSecure(sec);
|
saveSecure(sec);
|
||||||
|
|||||||
@@ -150,4 +150,10 @@ public abstract class SecureStore {
|
|||||||
|
|
||||||
/** @return list of stored entries. */
|
/** @return list of stored entries. */
|
||||||
public abstract Iterable<EntryKey> list();
|
public abstract Iterable<EntryKey> list();
|
||||||
|
|
||||||
|
/** @return <code>true</code> if currently loaded values are outdated */
|
||||||
|
public abstract boolean isOutdated();
|
||||||
|
|
||||||
|
/** Reload the values */
|
||||||
|
public abstract void reload();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user