You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jl...@apache.org on 2012/03/03 12:01:20 UTC

svn commit: r1296597 - /ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/Product.groovy

Author: jleroux
Date: Sat Mar  3 11:01:19 2012
New Revision: 1296597

URL: http://svn.apache.org/viewvc?rev=1296597&view=rev
Log:
A patch from Mike (mz4wheeler) "Product NOTFOUND causes java.lang.NullPointerException, ugly screen, and excessive logging" https://issues.apache.org/jira/browse/OFBIZ-4599

Fixes a possible NPE

Modified:
    ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/Product.groovy

Modified: ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/Product.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/Product.groovy?rev=1296597&r1=1296596&r2=1296597&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/Product.groovy (original)
+++ ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/Product.groovy Sat Mar  3 11:01:19 2012
@@ -43,14 +43,15 @@ metaKeywords = null;
 // get the product entity
 if (productId) {
     product = delegator.findByPrimaryKeyCache("Product", [productId : productId]);
-
-    // first make sure this isn't a virtual-variant that has an associated virtual product, if it does show that instead of the variant
-    if("Y".equals(product.isVirtual) && "Y".equals(product.isVariant)){
-        virtualVariantProductAssocs = delegator.findByAndCache("ProductAssoc", ["productId": productId, "productAssocTypeId": "ALTERNATIVE_PACKAGE"], ["-fromDate"]);
-        virtualVariantProductAssocs = EntityUtil.filterByDate(virtualVariantProductAssocs);
-        if (virtualVariantProductAssocs) {
-            productAssoc = EntityUtil.getFirst(virtualVariantProductAssocs);
-            product = productAssoc.getRelatedOneCache("AssocProduct");
+    if (product) {
+        // first make sure this isn't a virtual-variant that has an associated virtual product, if it does show that instead of the variant
+        if("Y".equals(product.isVirtual) && "Y".equals(product.isVariant)){
+            virtualVariantProductAssocs = delegator.findByAndCache("ProductAssoc", ["productId": productId, "productAssocTypeId": "ALTERNATIVE_PACKAGE"], ["-fromDate"]);
+            virtualVariantProductAssocs = EntityUtil.filterByDate(virtualVariantProductAssocs);
+            if (virtualVariantProductAssocs) {
+                productAssoc = EntityUtil.getFirst(virtualVariantProductAssocs);
+                product = productAssoc.getRelatedOneCache("AssocProduct");
+            }
         }
     }