From 773af1da352841f0e1c2ac86de0afe8e883d81ab Mon Sep 17 00:00:00 2001 From: weiminyu Date: Fri, 11 Jan 2019 13:34:09 -0800 Subject: [PATCH] Catch all errors in WhoisHttpAction Uncaught exception skips the call to metricBuilder.setNumResults() and triggers an AutoValue builder exception from the finally block. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=228936029 --- java/google/registry/whois/WhoisHttpAction.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/java/google/registry/whois/WhoisHttpAction.java b/java/google/registry/whois/WhoisHttpAction.java index 436d1deb0..8e8ec01fb 100644 --- a/java/google/registry/whois/WhoisHttpAction.java +++ b/java/google/registry/whois/WhoisHttpAction.java @@ -28,6 +28,7 @@ import static javax.servlet.http.HttpServletResponse.SC_OK; import com.google.common.base.Joiner; import com.google.common.base.Splitter; +import com.google.common.base.Throwables; import com.google.common.flogger.FluentLogger; import google.registry.config.RegistryConfig.Config; import google.registry.request.Action; @@ -37,7 +38,6 @@ import google.registry.request.auth.Auth; import google.registry.util.Clock; import google.registry.whois.WhoisMetrics.WhoisMetric; import google.registry.whois.WhoisResponse.WhoisResponseResults; -import java.io.IOException; import java.io.StringReader; import java.io.UnsupportedEncodingException; import java.net.URLDecoder; @@ -158,9 +158,10 @@ public final class WhoisHttpAction implements Runnable { metricBuilder.setStatus(e.getStatus()); metricBuilder.setNumResults(0); sendResponse(e.getStatus(), e); - } catch (IOException e) { + } catch (Throwable e) { metricBuilder.setStatus(SC_INTERNAL_SERVER_ERROR); metricBuilder.setNumResults(0); + Throwables.throwIfUnchecked(e); throw new RuntimeException(e); } finally { whoisMetrics.recordWhoisMetric(metricBuilder.build());