From b1e1dd0f473640cf72ef72f434b983d945dde5cc Mon Sep 17 00:00:00 2001 From: mcilwain Date: Sun, 31 Jul 2016 07:44:42 -0400 Subject: [PATCH] Remove toString() method on Result.Code and fix metrics recording We almost certainly had intended to record a String representation of the numeric Code all along, but a bad toString() method on the enum resulted in the wrong thing happening. This is more evidence of why overriding toString() on enums is bad. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=133583683 --- java/google/registry/flows/EppMetrics.java | 8 ++++++-- java/google/registry/model/eppoutput/Result.java | 5 ----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/java/google/registry/flows/EppMetrics.java b/java/google/registry/flows/EppMetrics.java index c0cad474b..108581bd6 100644 --- a/java/google/registry/flows/EppMetrics.java +++ b/java/google/registry/flows/EppMetrics.java @@ -55,18 +55,22 @@ public class EppMetrics { * @see FlowRunner */ public void incrementEppRequests(EppMetric metric) { + String eppStatusCode = + metric.getStatus().isPresent() ? String.valueOf(metric.getStatus().get().code) : ""; eppRequests.increment( metric.getCommandName().or(""), metric.getClientId().or(""), - metric.getStatus().isPresent() ? metric.getStatus().toString() : ""); + eppStatusCode); } /** Record the server-side processing time for an EPP request. */ public void recordProcessingTime(EppMetric metric) { + String eppStatusCode = + metric.getStatus().isPresent() ? String.valueOf(metric.getStatus().get().code) : ""; processingTime.record( metric.getEndTimestamp().getMillis() - metric.getStartTimestamp().getMillis(), metric.getCommandName().or(""), metric.getClientId().or(""), - metric.getStatus().isPresent() ? metric.getStatus().toString() : ""); + eppStatusCode); } } diff --git a/java/google/registry/model/eppoutput/Result.java b/java/google/registry/model/eppoutput/Result.java index 23f84de06..328fbdd0d 100644 --- a/java/google/registry/model/eppoutput/Result.java +++ b/java/google/registry/model/eppoutput/Result.java @@ -150,11 +150,6 @@ public class Result extends ImmutableObject { public boolean isSuccess() { return code < 2000; } - - @Override - public String toString() { - return String.format("{code:'%s', msg:'%s', msgLang:'%s'}", code, msg, msgLang); - } } /** The result code for this result. This is always present. */