Author: mbrohl
Date: Sat Dec 9 14:57:58 2017 New Revision: 1817618 URL: http://svn.apache.org/viewvc?rev=1817618&view=rev Log: Improved: Fixing defects reported by FindBugs, package org.apache.ofbiz.product.config. (OFBIZ-9774) Thanks Julian Leichert for reporting and providing the patch. Modified: ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigItemContentWrapper.java ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigWorker.java ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigWrapper.java Modified: ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigItemContentWrapper.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigItemContentWrapper.java?rev=1817618&r1=1817617&r2=1817618&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigItemContentWrapper.java (original) +++ ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigItemContentWrapper.java Sat Dec 9 14:57:58 2017 @@ -134,9 +134,7 @@ public class ProductConfigItemContentWra outString = outString == null? "" : outString; } outString = encoder.sanitize(outString, null); - if (configItemContentCache != null) { - configItemContentCache.put(cacheKey, outString); - } + configItemContentCache.put(cacheKey, outString); return outString; } catch (GeneralException e) { Debug.logError(e, "Error rendering ProdConfItemContent, inserting empty String", module); Modified: ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigWorker.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigWorker.java?rev=1817618&r1=1817617&r2=1817618&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigWorker.java (original) +++ ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigWorker.java Sat Dec 9 14:57:58 2017 @@ -405,7 +405,7 @@ public final class ProductConfigWorker { ProductConfigWrapper configWrapper = null; try { configWrapper = new ProductConfigWrapper(delegator, dispatcher, productId, productStoreId, catalogId, webSiteId, currencyUomId, locale, autoUserLogin); - if (configWrapper != null && UtilValidate.isNotEmpty(configId)) { + if (UtilValidate.isNotEmpty(configId)) { configWrapper.loadConfig(delegator, configId); } } catch (Exception e) { Modified: ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigWrapper.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigWrapper.java?rev=1817618&r1=1817617&r2=1817618&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigWrapper.java (original) +++ ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigWrapper.java Sat Dec 9 14:57:58 2017 @@ -222,6 +222,16 @@ public class ProductConfigWrapper implem } @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((delegatorName == null) ? 0 : delegatorName.hashCode()); + result = prime * result + ((product == null) ? 0 : product.hashCode()); + result = prime * result + ((questions == null) ? 0 : questions.hashCode()); + return result; + } + + @Override public boolean equals(Object obj) { if (!(obj instanceof ProductConfigWrapper)) { return false; @@ -775,6 +785,18 @@ public class ProductConfigWrapper implem return componentOptions; } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + getOuterType().hashCode(); + result = prime * result + ((componentList == null) ? 0 : componentList.hashCode()); + result = prime * result + ((componentOptions == null) ? 0 : componentOptions.hashCode()); + return result; + } + + @Override public boolean equals(Object obj) { if (obj == null || !(obj instanceof ConfigOption)) { @@ -788,11 +810,16 @@ public class ProductConfigWrapper implem return isSelected() == co.isSelected(); } + @Override public String toString() { return configOption.getString("configItemId") + "/" + configOption.getString("configOptionId") + (isSelected()? "*": ""); } + private ProductConfigWrapper getOuterType() { + return ProductConfigWrapper.this; + } + } } |
Free forum by Nabble | Edit this page |