Minor refactoring in Reindex program

We don't need a Config instance in the class scope any more, since
it's only used in the checkNotSlaveMode method.

Change-Id: I6a9128201ca858ce5986bc6045b363653f2ab843
This commit is contained in:
David Pursehouse
2014-09-10 13:42:11 +02:00
parent ecc535c6ff
commit d0a9f71a92

View File

@@ -84,7 +84,6 @@ public class Reindex extends SiteProgram {
private boolean dryRun; private boolean dryRun;
private Injector dbInjector; private Injector dbInjector;
private Config cfg;
private Injector sysInjector; private Injector sysInjector;
private ChangeIndex index; private ChangeIndex index;
@@ -93,8 +92,6 @@ public class Reindex extends SiteProgram {
mustHaveValidSite(); mustHaveValidSite();
dbInjector = createDbInjector(MULTI_USER); dbInjector = createDbInjector(MULTI_USER);
threads = ThreadLimiter.limitThreads(dbInjector, threads); threads = ThreadLimiter.limitThreads(dbInjector, threads);
cfg = dbInjector.getInstance(
Key.get(Config.class, GerritServerConfig.class));
checkNotSlaveMode(); checkNotSlaveMode();
disableLuceneAutomaticCommit(); disableLuceneAutomaticCommit();
if (version == null) { if (version == null) {
@@ -125,6 +122,8 @@ public class Reindex extends SiteProgram {
} }
private void checkNotSlaveMode() throws Die { private void checkNotSlaveMode() throws Die {
Config cfg = dbInjector.getInstance(
Key.get(Config.class, GerritServerConfig.class));
if (cfg.getBoolean("container", "slave", false)) { if (cfg.getBoolean("container", "slave", false)) {
throw die("Cannot run reindex in slave mode"); throw die("Cannot run reindex in slave mode");
} }