Author: jleroux
Date: Sun Feb 11 18:51:37 2018
New Revision: 1823877
URL: http://svn.apache.org/viewvc?rev=1823877&view=rev
Log:
"Applied fix from trunk for revision: 1823876"
------------------------------------------------------------------------
r1823876 | jleroux | 2018-02-11 19:51:07 +0100 (dim., 11 févr. 2018) | 9 lines
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()
------------------------------------------------------------------------
Modified:
ofbiz/ofbiz-framework/branches/release17.12/ (props changed)
ofbiz/ofbiz-framework/branches/release17.12/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilNumber.java
Propchange: ofbiz/ofbiz-framework/branches/release17.12/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Feb 11 18:51:37 2018
@@ -10,4 +10,4 @@
/ofbiz/branches/json-integration-refactoring:1634077-1635900
/ofbiz/branches/multitenant20100310:921280-927264
/ofbiz/branches/release13.07:1547657
-/ofbiz/ofbiz-framework/trunk:1819499,1819598,1819800,1819805,1819811,1820038,1820262,1820374-1820375,1820441,1820457,1820644,1820658,1820790,1820823,1820949,1820966,1821012,1821036,1821112,1821115,1821144,1821186,1821219,1821226,1821230,1821386,1821600,1821613,1821628,1821965,1822125,1822310,1822377,1822383,1822393,1822882,1823324,1823467,1823562
+/ofbiz/ofbiz-framework/trunk:1819499,1819598,1819800,1819805,1819811,1820038,1820262,1820374-1820375,1820441,1820457,1820644,1820658,1820790,1820823,1820949,1820966,1821012,1821036,1821112,1821115,1821144,1821186,1821219,1821226,1821230,1821386,1821600,1821613,1821628,1821965,1822125,1822310,1822377,1822383,1822393,1822882,1823324,1823467,1823562,1823876
Modified:
ofbiz/ofbiz-framework/branches/release17.12/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilNumber.java
URL:
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/branches/release17.12/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilNumber.java?rev=1823877&r1=1823876&r2=1823877&view=diff
==============================================================================
---
ofbiz/ofbiz-framework/branches/release17.12/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilNumber.java
(original)
+++
ofbiz/ofbiz-framework/branches/release17.12/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilNumber.java
Sun Feb 11 18:51:37 2018
@@ -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;
}