Author: mbrohl
Date: Mon Jan 14 14:07:35 2019 New Revision: 1851254 URL: http://svn.apache.org/viewvc?rev=1851254&view=rev Log: Fixed: Blank page is displayed on ecommerce (OFBIZ-10741) Fixed recursions in hashCode methods introduced wth OFBIZ-9774. Thanks Arpit Mor for reporting, Jacques Le Roux amd Priya Sharma for review and helpful hints. Modified: 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/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=1851254&r1=1851253&r2=1851254&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 Mon Jan 14 14:07:35 2019 @@ -531,36 +531,25 @@ public class ProductConfigWrapper implem } @Override - public boolean equals(Object obj) { - if (obj == null || !(obj instanceof ConfigItem)) { - return false; - } - ConfigItem ci = (ConfigItem)obj; - if (!configItem.getString("configItemId").equals(ci.getConfigItem().getString("configItemId"))) { - return false; - } - List<ConfigOption> opts = ci.getOptions(); - if (options.size() != opts.size()) { - return false; - } - for (int i = 0; i < options.size(); i++) { - ConfigOption co = options.get(i); - if (!co.equals(opts.get(i))) { - return false; - } - } - return true; + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + ConfigItem that = (ConfigItem) o; + return Objects.equals(getConfigItem(), that.getConfigItem()) && + Objects.equals(getConfigItemAssoc(), that.getConfigItemAssoc()) && + Objects.equals(getOptions(), that.getOptions()); } @Override - public String toString() { - return configItem.getString("configItemId"); + public int hashCode() { + return Objects.hash(getConfigItem(), getConfigItemAssoc(), getOptions()); } @Override - public int hashCode() { - return Objects.hash(configItem, configItemAssoc, content, options, first); + public String toString() { + return configItem.getString("configItemId"); } + } public class ConfigOption implements java.io.Serializable { @@ -815,41 +804,27 @@ 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; + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + ConfigOption that = (ConfigOption) o; + return Objects.equals(availabilityDate, that.availabilityDate) && + Objects.equals(componentList, that.componentList) && + Objects.equals(getComponentOptions(), that.getComponentOptions()) && + Objects.equals(configOption, that.configOption); } - @Override - public boolean equals(Object obj) { - if (obj == null || !(obj instanceof ConfigOption)) { - return false; - } - ConfigOption co = (ConfigOption)obj; - if (componentOptions != null && !componentOptions.equals(co.getComponentOptions())) { - return false; - } - - return isSelected() == co.isSelected(); + public int hashCode() { + return Objects.hash(availabilityDate, componentList, getComponentOptions(), configOption); } - @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 |