summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn O. Pearce <sop@google.com>2009-05-15 21:38:11 -0700
committerShawn O. Pearce <sop@google.com>2009-05-15 21:38:11 -0700
commited021858d03ef6399eb0fc28e69216a2640aa9b4 (patch)
tree6c195aa501ca5e5a2d5355124a05df83f9e2b0a0
parent1e05ed77b80b86d798cdee570b8dd0a7a55b4b80 (diff)
Detect cases where system_config has too many rows
Sometimes when setting up a new server a user can find a way to insert multiple rows into the system_config table. Instead of honoring one of them seemingly at ranodm (and ignoring the other rows that may have critical data in them) we now abort at startup with a description of the problem. Signed-off-by: Shawn O. Pearce <sop@google.com>
-rw-r--r--src/main/java/com/google/gerrit/server/GerritServer.java13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/main/java/com/google/gerrit/server/GerritServer.java b/src/main/java/com/google/gerrit/server/GerritServer.java
index 19729fc9ec..e4aa34b576 100644
--- a/src/main/java/com/google/gerrit/server/GerritServer.java
+++ b/src/main/java/com/google/gerrit/server/GerritServer.java
@@ -76,6 +76,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
+import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
@@ -634,7 +635,17 @@ public class GerritServer {
}
if (sVer.versionNbr == ReviewDb.VERSION) {
- sConfig = c.systemConfig().get(new SystemConfig.Key());
+ final List<SystemConfig> all = c.systemConfig().all().toList();
+ switch (all.size()) {
+ case 0:
+ throw new OrmException("system_config table is empty");
+ case 1:
+ sConfig = all.get(0);
+ break;
+ default:
+ throw new OrmException("system_config must have exactly 1 row;"
+ + " found " + all.size() + " rows instead");
+ }
} else {
throw new OrmException("Unsupported schema version " + sVer.versionNbr