Skip to content

Commit d242280

Browse files
committed
Improved: Possible NPE in PayPal services (OFBIZ-13385)
Thanks: Vitaly Repetenko for a better code
1 parent 45e8808 commit d242280

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

  • applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/paypal

applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/paypal/PayPalServices.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,9 @@ public class PayPalServices {
9494

9595
public static Map<String, Object> setExpressCheckout(DispatchContext dctx, Map<String, ? extends Object> context) {
9696
ShoppingCart cart = (ShoppingCart) context.get("cart");
97-
if (cart != null ) {
98-
Locale locale = cart.getLocale();
99-
if (cart.items().isEmpty() {
100-
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE,
101-
"AccountingPayPalShoppingCartIsEmpty", locale));
102-
}
97+
if (cart == null || cart.isEmpty()) {
98+
  return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE,
99+
       "AccountingPayPalShoppingCartIsEmpty", (cart == null || cart.getLocale() == null) ? Locale.US : cart.getLocale()));
103100
}
104101

105102
GenericValue payPalConfig = getPaymentMethodGatewayPayPal(dctx, context, null);

0 commit comments

Comments
 (0)