From b7fd8de1cf7ba0593112d277bb2a75d94a1e6571 Mon Sep 17 00:00:00 2001 From: Dave Borowitz Date: Mon, 12 May 2014 11:54:35 -0700 Subject: [PATCH] Omit corrupt changes from search results A single corrupt change, e.g. with a missing current patch set, can potentially prevent a search results page from loading by causing the whole query to return a 500. Instead of hosing search results, omit corrupt changes from the results with a warning in the logs. The downside of this approach is that in the presence of corrupt changes, it is no longer guaranteed that _more_changes will be set on the last result only if there were N results. On balance I think this is a fair price to keep the web UI usable for users in this rare error case. Change-Id: I1a2a24877156c55243513b03207137d412bc8bfd --- .../java/com/google/gerrit/server/change/ChangeJson.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/change/ChangeJson.java b/gerrit-server/src/main/java/com/google/gerrit/server/change/ChangeJson.java index 6bc7b7a926..975fbb1518 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/change/ChangeJson.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/change/ChangeJson.java @@ -278,7 +278,12 @@ public class ChangeJson { for (ChangeData cd : changes) { ChangeInfo i = out.get(cd.getId()); if (i == null) { - i = toChangeInfo(cd, Optional. absent()); + try { + i = toChangeInfo(cd, Optional. absent()); + } catch (OrmException e) { + log.warn( + "Omitting corrupt change " + cd.getId() + " from results", e); + } out.put(cd.getId(), i); } info.add(i);