Author: mbrohl
Date: Fri Jul 7 15:33:39 2017
New Revision: 1801183
URL:
http://svn.apache.org/viewvc?rev=1801183&view=revLog:
Improved: Fixing defects reported by FindBugs.
(OFBIZ-9451)
Use a StringBuilder to append a certain amount of '*'s to origMaskedNumber.
When using concatenation inside the loop, the String is converted to a new
StringBuilder, appended to, and then converted back to a String anyway.
Therefore the performance is improved by avoiding many StringBuilder
initializations.
ReturnHeaderResp in RefundGcPurchase() is unnecessarily checked for null value.
Modified:
ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentMethodServices.java
Modified: ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentMethodServices.java
URL:
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentMethodServices.java?rev=1801183&r1=1801182&r2=1801183&view=diff==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentMethodServices.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentMethodServices.java Fri Jul 7 15:33:39 2017
@@ -301,12 +301,14 @@ public class PaymentMethodServices {
if (updatedCardNumber.startsWith("*")) {
// get the masked card number from the db
String origCardNumber = creditCard.getString("cardNumber");
- String origMaskedNumber = "";
int cardLength = origCardNumber.length() - 4;
+
+ // use builder for better performance
+ StringBuilder builder = new StringBuilder();
for (int i = 0; i < cardLength; i++) {
- origMaskedNumber = origMaskedNumber + "*";
+ builder.append("*");
}
- origMaskedNumber = origMaskedNumber + origCardNumber.substring(cardLength);
+ String origMaskedNumber = builder.append(origCardNumber.substring(cardLength)).toString();
// compare the two masked numbers
if (updatedCardNumber.equals(origMaskedNumber)) {
@@ -1117,8 +1119,8 @@ public class PaymentMethodServices {
result.put("paymentMethodId", paymentMethodId);
result.put("oldPaymentMethodId", paymentMethodId);
result.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_SUCCESS);
- result.put(ModelService.SUCCESS_MESSAGE, UtilProperties.getMessage(resource,
- "AccountingCheckAccountCannotBeUpdated", locale));
+ result.put(ModelService.SUCCESS_MESSAGE,
+ UtilProperties.getMessage(resource, "AccountingCheckAccountCannotBeUpdated", locale));
return result;
}