From 45f5c24ed058c7b491e2c4365020b00329ea6726 Mon Sep 17 00:00:00 2001 From: Jacques Le Roux Date: Sun, 11 Feb 2018 18:51:37 +0000 Subject: [PATCH] =?UTF-8?q?"Applied=20fix=20from=20trunk=20for=20revision:?= =?UTF-8?q?=201823876"=20-------------------------------------------------?= =?UTF-8?q?-----------------------=20r1823876=20|=20jleroux=20|=202018-02-?= =?UTF-8?q?11=2019:51:07=20+0100=20(dim.,=2011=20f=C3=A9vr.=202018)=20|=20?= =?UTF-8?q?9=20lines?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixed: UtilNumber.getBigDecimalRoundingMode() returns a wrong value (OFBIZ-10218) While working on OFBIZ-9571 I found that getBigDecimalRoundingMode() returns DEFAULT_BD_SCALE when the passed value for the file parameter is emtpy. This has certainly be C/P from getBigDecimalScale() and never found before. While at it I refactored a bit getBigDecimalRoundingMode() and getBigDecimalScale() ------------------------------------------------------------------------ git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/branches/release17.12@1823877 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/ofbiz/base/util/UtilNumber.java | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilNumber.java b/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilNumber.java index c3eefecaaf..b389217b87 100644 --- a/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilNumber.java +++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilNumber.java @@ -183,13 +183,10 @@ public final class UtilNumber { * @return int - Scale factor to pass to BigDecimal's methods. Defaults to DEFAULT_BD_SCALE (2) */ public static int getBigDecimalScale(String file, String property) { - if (UtilValidate.isEmpty(file)) { + if (UtilValidate.isEmpty(file) || UtilValidate.isEmpty(property)) { return DEFAULT_BD_SCALE; } - if (UtilValidate.isEmpty(property)) { - return DEFAULT_BD_SCALE; - } - + int scale = -1; String value = UtilProperties.getPropertyValue(file, property); try { @@ -217,10 +214,7 @@ public final class UtilNumber { * @return int - Rounding mode to pass to BigDecimal's methods. Defaults to DEFAULT_BD_ROUNDING_MODE (BigDecimal.ROUND_HALF_UP) */ public static int getBigDecimalRoundingMode(String file, String property) { - if (UtilValidate.isEmpty(file)) { - return DEFAULT_BD_SCALE; - } - if (UtilValidate.isEmpty(property)) { + if (UtilValidate.isEmpty(file) || UtilValidate.isEmpty(property)) { return DEFAULT_BD_ROUNDING_MODE; }