Thanks Jacopo,

You are right about PR. That looked so easy and I did not saw all points. I'll 
fix that.

Jacques

Le 14/04/2026 à 16:02, Jacopo Cappellato a écrit :
Hi Jacques,

Your commit can't fix the NPE issue since the null check you introduced is
performed after the getLocale method is called on the reference to the cart
object.
If you had created a pull request, we could have avoided this commit by
reviewing your changes. Please consider the advice I gave you yesterday:
create a branch in your fork and submit a pull request from there.

Jacopo

On Tue, Apr 14, 2026 at 3:34 PM <[email protected]> wrote:

This is an automated email from the ASF dual-hosted git repository.

jleroux pushed a commit to branch release24.09
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git

commit 1d6d655a75056272211fd9bf0a8aaad3c53951d4
Author: Jacques Le Roux <[email protected]>
AuthorDate: Tue Apr 14 14:57:40 2026 +0200

     Fixed: Possible NPE in PayPal services (OFBIZ-13385)

     In PayPalServices::setExpressCheckout, using cart before checking if
it is null

     ShoppingCart cart = (ShoppingCart) context.get("cart");
     Locale locale = cart.getLocale();
     if (cart == null || cart.items().size() <= 0) {
         return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE,
                  "AccountingPayPalShoppingCartIsEmpty", locale));
     }

     Thanks: Vitaly Repetenko
---
  .../apache/ofbiz/accounting/thirdparty/paypal/PayPalServices.java | 8
+++++---
  1 file changed, 5 insertions(+), 3 deletions(-)

diff --git
a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/paypal/PayPalServices.java
b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/paypal/PayPalServices.java
index 3c1888fea3..32f9f0386c 100644
---
a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/paypal/PayPalServices.java
+++
b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/paypal/PayPalServices.java
@@ -95,9 +95,11 @@ public class PayPalServices {
      public static Map<String, Object> setExpressCheckout(DispatchContext
dctx, Map<String, ? extends Object> context) {
          ShoppingCart cart = (ShoppingCart) context.get("cart");
          Locale locale = cart.getLocale();
-        if (cart == null || cart.items().size() <= 0) {
-            return
ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE,
-                    "AccountingPayPalShoppingCartIsEmpty", locale));
+        if (cart != null ) {
+            if (cart.items().size() <= 0) {
+                return
ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE,
+                        "AccountingPayPalShoppingCartIsEmpty", locale));
+            }
          }

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


Reply via email to