svn commit: r1851255 - in /ofbiz/ofbiz-framework/branches/release18.12: ./ applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigWrapper.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1851255 - in /ofbiz/ofbiz-framework/branches/release18.12: ./ applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigWrapper.java

mbrohl
Author: mbrohl
Date: Mon Jan 14 14:13:27 2019
New Revision: 1851255

URL: http://svn.apache.org/viewvc?rev=1851255&view=rev
Log:
Applied fix from trunk for revision: 1851254
===

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/branches/release18.12/   (props changed)
    ofbiz/ofbiz-framework/branches/release18.12/applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigWrapper.java

Propchange: ofbiz/ofbiz-framework/branches/release18.12/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Jan 14 14:13:27 2019
@@ -10,4 +10,4 @@
 /ofbiz/branches/json-integration-refactoring:1634077-1635900
 /ofbiz/branches/multitenant20100310:921280-927264
 /ofbiz/branches/release13.07:1547657
-/ofbiz/ofbiz-framework/trunk:1850015,1850023,1850530,1850647,1850685,1850694,1850711,1850914,1850918,1850921,1850948,1850953,1851006,1851013,1851068,1851074,1851130,1851158,1851200,1851224,1851247
+/ofbiz/ofbiz-framework/trunk:1850015,1850023,1850530,1850647,1850685,1850694,1850711,1850914,1850918,1850921,1850948,1850953,1851006,1851013,1851068,1851074,1851130,1851158,1851200,1851224,1851247,1851254

Modified: ofbiz/ofbiz-framework/branches/release18.12/applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigWrapper.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/branches/release18.12/applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigWrapper.java?rev=1851255&r1=1851254&r2=1851255&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/branches/release18.12/applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigWrapper.java (original)
+++ ofbiz/ofbiz-framework/branches/release18.12/applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigWrapper.java Mon Jan 14 14:13:27 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;
-        }
-
     }
 
 }