From b2d5108c0c59f9d56ae392612c729ad5b764b8d7 Mon Sep 17 00:00:00 2001 From: Chris Tingue Date: Mon, 1 Aug 2016 13:59:50 -0700 Subject: [PATCH] Prefer Money.zero over Money.of(currency, 0) In the case where currency has a zero scale (i.e. JPY), Money.of(currency, 0) throws ArithmeticException because the second argument is handled as a double, and JPY (for example) does not allow decimal precision, even if the decimal is zero. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=129023540 --- java/google/registry/pricing/TldSpecificLogicProxy.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/google/registry/pricing/TldSpecificLogicProxy.java b/java/google/registry/pricing/TldSpecificLogicProxy.java index ef80e69df..6b2fa8e0d 100644 --- a/java/google/registry/pricing/TldSpecificLogicProxy.java +++ b/java/google/registry/pricing/TldSpecificLogicProxy.java @@ -56,7 +56,7 @@ public final class TldSpecificLogicProxy { * Returns the total cost of all fees for the event. */ public Money getTotalCost() { - Money result = Money.of(currency, 0); + Money result = Money.zero(currency); for (Fee fee : fees) { result = result.plus(fee.getCost()); }