Hi Jacques,I don't think this commit is going to behave the way you expect it to, comments inline.
Regards Scott HotWax Media http://www.hotwaxmedia.com On 24/12/2009, at 12:26 PM, [email protected] wrote:
Author: jleroux Date: Wed Dec 23 23:26:33 2009 New Revision: 893656 URL: http://svn.apache.org/viewvc?rev=893656&view=rev Log:Fix a possible NPE (in POS but I guess not only) when a Product have been created without a ProductType associated (from import data).The reason of this informative log is to facilitate the search then... Can't hurt anyway Modified:ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ ShoppingCartItem.javaModified: ofbiz/trunk/applications/order/src/org/ofbiz/order/ shoppingcart/ShoppingCartItem.javaURL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java?rev=893656&r1=893655&r2=893656&view=diff= = = = = = = = ====================================================================== --- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ ShoppingCartItem.java (original) +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ ShoppingCartItem.java Wed Dec 23 23:26:33 2009@@ -716,10 +716,16 @@ if (parentProduct != null)this.parentProductId = _parentProduct.getString("productId");if (UtilValidate.isEmpty(itemType)) {- if (_product.getString("productTypeId").equals("ASSET_USAGE")) { - this.itemType = "RENTAL_ORDER_ITEM"; // will create additional workeffort/asset usage records+ if (UtilValidate.isNotEmpty(_product)) {
_product can't be null here because earlier code would have thrown an NPE already. Don't you actually want to check if _product.getString("productTypeId") is null?
also the actual NPE fix is to do this:
if ("ASSET_USAGE".equals(_product.getString("productTypeId))) {
+ if (_product.getString("productTypeId").equals("ASSET_USAGE")) { + this.itemType = "RENTAL_ORDER_ITEM"; // will create additional workeffort/asset usage records+ } else { + this.itemType = "PRODUCT_ORDER_ITEM"; + } } else { - this.itemType = "PRODUCT_ORDER_ITEM";+ Debug.logError("Error calling ShoppingCartItem (trying to creates new ShoppingCartItem object)." ++ " Check that there is a type for this product ", module); + return; } } else { this.itemType = itemType;
smime.p7s
Description: S/MIME cryptographic signature
