Take into account that config read could fail on start() If there is a problem reading All-Projects when the plugin is started, the plugin configuration is null and this can cause a NullPointerException later. Consider a null config "no configs" when finding relevant entries. In the REST call, return a 500 with an appropiate message. Change-Id: Iff503f74ffcff25b160c46486909e4ee367475c9
diff --git a/java/com/googlesource/gerrit/plugins/supermanifest/SuperManifestRefUpdatedListener.java b/java/com/googlesource/gerrit/plugins/supermanifest/SuperManifestRefUpdatedListener.java index d31f660..d6f471d 100644 --- a/java/com/googlesource/gerrit/plugins/supermanifest/SuperManifestRefUpdatedListener.java +++ b/java/com/googlesource/gerrit/plugins/supermanifest/SuperManifestRefUpdatedListener.java
@@ -252,6 +252,9 @@ /** for debugging. */ private String configurationToString() { + if (config == null) { + return "No config loaded (could not read All-Projects)"; + } StringBuilder b = new StringBuilder(); b.append("Supermanifest config (").append(config.size()).append(") {\n"); for (ConfigEntry c : config) { @@ -331,6 +334,13 @@ identifiedUser.get().getAccountId().get(), configurationToString()); + if (config == null) { + error( + "Plugin could not read conf from All-Projects (processing %s:%s)", + manifestProject, manifestBranch); + throw new PreconditionFailedException("Plugin could not read conf from All-Projects"); + } + List<ConfigEntry> relevantConfigs = findRelevantConfigs(resource.getProjectState().getProject().getName(), resource.getRef()); if (relevantConfigs.isEmpty()) { @@ -355,6 +365,9 @@ private List<ConfigEntry> findRelevantConfigs(String project, String refName) { List<ConfigEntry> relevantConfigs = new ArrayList<>(); + if (config == null) { + return relevantConfigs; + } for (ConfigEntry c : config) { if (!c.srcRepoKey.get().equals(project)) { continue;