You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by mb...@apache.org on 2017/08/18 19:39:26 UTC

svn commit: r1805463 - /ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/finaccount/FinAccountPaymentServices.java

Author: mbrohl
Date: Fri Aug 18 19:39:26 2017
New Revision: 1805463

URL: http://svn.apache.org/viewvc?rev=1805463&view=rev
Log:
Improved: Fixing defects reported by FindBugs, package 
org.apache.ofbiz.accounting.finaccount
(OFBIZ-9504)

FinAccountPaymentServices.finAccountPreAuth(DispatchContext, Map)
A value is checked here to see whether it is null, but this value can't 
be null because it was previously dereferenced and if it were null a 
null pointer exception would have occurred at the earlier dereference. 
Essentially, this code and the previous dereference disagree as to 
whether this value is allowed to be null. 
Either the check is redundant or the previous dereference is erroneous.

Thanks Kyra Pritzel-Hentley for reporting and providing the patch.

Modified:
    ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/finaccount/FinAccountPaymentServices.java

Modified: ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/finaccount/FinAccountPaymentServices.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/finaccount/FinAccountPaymentServices.java?rev=1805463&r1=1805462&r2=1805463&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/finaccount/FinAccountPaymentServices.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/finaccount/FinAccountPaymentServices.java Fri Aug 18 19:39:26 2017
@@ -68,19 +68,22 @@ public class FinAccountPaymentServices {
         String orderId = (String) context.get("orderId");
         BigDecimal amount = (BigDecimal) context.get("processAmount");
 
-        // check for an existing auth trans and cancel it
-        GenericValue authTrans = PaymentGatewayServices.getAuthTransaction(paymentPref);
-        if (authTrans != null) {
-            Map<String, Object> input = UtilMisc.toMap("userLogin", userLogin, "finAccountAuthId", authTrans.get("referenceNum"));
-            try {
-                dispatcher.runSync("expireFinAccountAuth", input);
-            } catch (GenericServiceException e) {
-                Debug.logError(e, module);
-                return ServiceUtil.returnError(e.getMessage());
+        if (paymentPref != null) {
+            // check for an existing auth trans and cancel it
+            GenericValue authTrans = PaymentGatewayServices.getAuthTransaction(paymentPref);
+            if (authTrans != null) {
+                Map<String, Object> input = UtilMisc.toMap("userLogin", userLogin, "finAccountAuthId",
+                        authTrans.get("referenceNum"));
+                try {
+                    dispatcher.runSync("expireFinAccountAuth", input);
+                } catch (GenericServiceException e) {
+                    Debug.logError(e, module);
+                    return ServiceUtil.returnError(e.getMessage());
+                }
+            }
+            if (finAccountId == null) {
+                finAccountId = paymentPref.getString("finAccountId");
             }
-        }
-        if (finAccountId == null && paymentPref != null) {
-            finAccountId = paymentPref.getString("finAccountId");
         }
 
         // obtain the order information