From 78ce104d7e19bce3dcc736e4e53a662ffc4209be Mon Sep 17 00:00:00 2001 From: Jacques Le Roux Date: Sat, 12 Aug 2017 07:59:16 +0000 Subject: [PATCH] Reverted: [FB] Package org.apache.ofbiz.accounting.payment (Additional Bugs) (OFBIZ-9529) GiftCertificateServices.java:229, DLS_DEAD_LOCAL_STORE GiftCertificateServices.java:306, DLS_DEAD_LOCAL_STORE DLS: Dead store to balance in GiftCertificateServices.addFundsToGiftCertificate(DispatchContext, Map) This instruction assigns a value to a local variable, but the value is not read or used in any subsequent instruction. Often, this indicates an error, because the value computed is never used. It was late and I was too quick yesterday night. I see no reason why we would replace ZERO by null (no assignment) in both cases, the variables are used. So I revert r1804847 and I rather replace occurrences of BigDecimal.ZERO by the locally defined constant ZERO git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1804859 13f79535-47bb-0310-9956-ffa450edef68 --- .../accounting/payment/GiftCertificateServices.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/GiftCertificateServices.java b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/GiftCertificateServices.java index b13214a919..bc9192069d 100644 --- a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/GiftCertificateServices.java +++ b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/GiftCertificateServices.java @@ -226,7 +226,7 @@ public class GiftCertificateServices { } // create the transaction - BigDecimal balance; + BigDecimal balance = ZERO; String refNum = null; try { refNum = GiftCertificateServices.createTransaction(delegator, dispatcher, userLogin, amount, productStoreId, partyId, @@ -270,7 +270,7 @@ public class GiftCertificateServices { } // validate the amount - if (amount.compareTo(BigDecimal.ZERO) < 0) { + if (amount.compareTo(ZERO) < 0) { return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, "AccountingFinAccountMustBePositive", locale)); } @@ -301,9 +301,9 @@ public class GiftCertificateServices { } // check the actual balance (excluding authorized amounts) and create the transaction if it is sufficient - BigDecimal previousBalance = finAccount.get("actualBalance") == null ? BigDecimal.ZERO : finAccount.getBigDecimal("actualBalance"); + BigDecimal previousBalance = finAccount.get("actualBalance") == null ? ZERO : finAccount.getBigDecimal("actualBalance"); - BigDecimal balance; + BigDecimal balance = ZERO; String refNum = null; Boolean procResult; if (previousBalance.compareTo(amount) >= 0) { @@ -311,7 +311,7 @@ public class GiftCertificateServices { refNum = GiftCertificateServices.createTransaction(delegator, dispatcher, userLogin, amount, productStoreId, partyId, currencyUom, withdrawl, cardNumber, locale); finAccount.refresh(); - balance = finAccount.get("availableBalance") == null ? BigDecimal.ZERO : finAccount.getBigDecimal("availableBalance"); + balance = finAccount.get("availableBalance") == null ? ZERO : finAccount.getBigDecimal("availableBalance"); procResult = Boolean.TRUE; } catch (GeneralException e) { Debug.logError(e, module); @@ -356,7 +356,7 @@ public class GiftCertificateServices { // TODO: get the real currency from context // get the balance - BigDecimal balance = finAccount.get("availableBalance") == null ? BigDecimal.ZERO : finAccount.getBigDecimal("availableBalance"); + BigDecimal balance = finAccount.get("availableBalance") == null ? ZERO : finAccount.getBigDecimal("availableBalance"); Map result = ServiceUtil.returnSuccess(); result.put("balance", balance);