svn commit: r1801171 - /ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/GiftCertificateServices.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1801171 - /ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/GiftCertificateServices.java

mbrohl
Author: mbrohl
Date: Fri Jul  7 14:44:21 2017
New Revision: 1801171

URL: http://svn.apache.org/viewvc?rev=1801171&view=rev
Log:
Improved: Fixing defects reported by FindBugs.
(OFBIZ-9451)

Set BigDecimal ZERO to final to avoid changes by malicious code from the outside
or changes that happen by accident from another package.

ReturnHeaderResp in RefundGcPurchase() is unnecessarily checked for null value.

Modified:
    ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/GiftCertificateServices.java

Modified: ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/GiftCertificateServices.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/GiftCertificateServices.java?rev=1801171&r1=1801170&r2=1801171&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/GiftCertificateServices.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/GiftCertificateServices.java Fri Jul  7 14:44:21 2017
@@ -56,7 +56,7 @@ public class GiftCertificateServices {
     public static final int CARD_NUMBER_LENGTH = 14;
     public static final int PIN_NUMBER_LENGTH = 6;
 
-    public static BigDecimal ZERO = BigDecimal.ZERO;
+    public static final BigDecimal ZERO = BigDecimal.ZERO;
 
     // Base Gift Certificate Services
     public static Map<String, Object> createGiftCertificate(DispatchContext dctx, Map<String, ? extends Object> context) {
@@ -1238,18 +1238,14 @@ public class GiftCertificateServices {
                         "OrderErrorUnableToCreateReturnHeader", locale));
             }
 
-            if (returnHeaderResp != null) {
-                String errorMessage = ServiceUtil.getErrorMessage(returnHeaderResp);
-                if (errorMessage != null) {
-                    return ServiceUtil.returnError(errorMessage);
-                }
-            }
-
-            String returnId = null;
-            if (returnHeaderResp != null) {
-                returnId = (String) returnHeaderResp.get("returnId");
+            String errorMessage = ServiceUtil.getErrorMessage(returnHeaderResp);
+            if (errorMessage != null) {
+                return ServiceUtil.returnError(errorMessage);
             }
+            
+            String returnId = (String) returnHeaderResp.get("returnId");
 
+            
             if (returnId == null) {
                 return ServiceUtil.returnError(UtilProperties.getMessage(resourceOrderError,
                         "OrderErrorCreateReturnHeaderWithoutId", locale));
@@ -1276,17 +1272,12 @@ public class GiftCertificateServices {
                         "OrderErrorUnableToCreateReturnItem", locale));
             }
 
-            if (returnItemResp != null) {
-                String errorMessage = ServiceUtil.getErrorMessage(returnItemResp);
-                if (errorMessage != null) {
-                    return ServiceUtil.returnError(errorMessage);
-                }
+            errorMessage = ServiceUtil.getErrorMessage(returnItemResp);
+            if (errorMessage != null) {
+                return ServiceUtil.returnError(errorMessage);
             }
 
-            String returnItemSeqId = null;
-            if (returnItemResp != null) {
-                returnItemSeqId = (String) returnItemResp.get("returnItemSeqId");
-            }
+            String returnItemSeqId = (String) returnItemResp.get("returnItemSeqId");
 
             if (returnItemSeqId == null) {
                 return ServiceUtil.returnError(UtilProperties.getMessage(resourceOrderError,
@@ -1320,11 +1311,9 @@ public class GiftCertificateServices {
                         "OrderErrorUnableToUpdateReturnHeaderStatus", locale));
             }
 
-            if (updateReturnResp != null) {
-                String errorMessage = ServiceUtil.getErrorMessage(updateReturnResp);
-                if (errorMessage != null) {
-                    return ServiceUtil.returnError(errorMessage);
-                }
+            errorMessage = ServiceUtil.getErrorMessage(updateReturnResp);
+            if (errorMessage != null) {
+                return ServiceUtil.returnError(errorMessage);
             }
         }