This commit does not make sense and it is unnecessary. Please revert it.
Adrian Crum Sandglass Software www.sandglass-software.com On 6/7/2015 9:03 AM, [hidden email] wrote: > Author: jleroux > Date: Sun Jun 7 16:03:04 2015 > New Revision: 1684042 > > URL: http://svn.apache.org/r1684042 > Log: > A patch from Taher Alkhateeb "Upgrade OFBiz to Java JDK 8" https://issues.apache.org/jira/browse/OFBIZ-6458 > 1st step: fixes a test which was not passing > > Modified: > ofbiz/trunk/framework/base/src/org/ofbiz/base/util/StringUtil.java > > Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/StringUtil.java > URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/StringUtil.java?rev=1684042&r1=1684041&r2=1684042&view=diff > ============================================================================== > --- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/StringUtil.java (original) > +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/StringUtil.java Sun Jun 7 16:03:04 2015 > @@ -24,6 +24,7 @@ import java.net.URLEncoder; > import java.util.Collection; > import java.util.HashMap; > import java.util.Iterator; > +import java.util.LinkedHashMap; > import java.util.LinkedHashSet; > import java.util.LinkedList; > import java.util.List; > @@ -48,7 +49,7 @@ public class StringUtil { > protected static final Map<String, Pattern> substitutionPatternMap; > > static { > - substitutionPatternMap = new HashMap<String, Pattern>(); > + substitutionPatternMap = new LinkedHashMap<String, Pattern>(); > substitutionPatternMap.put("&&", Pattern.compile("@and", Pattern.LITERAL)); > substitutionPatternMap.put("||", Pattern.compile("@or", Pattern.LITERAL)); > substitutionPatternMap.put("<=", Pattern.compile("@lteq", Pattern.LITERAL)); > > |
Hi Adrian,
In JDK 8 the HashMap does not respect order of insertion. I explained this bug earlier in detail. Please take a look at what i wrote and you will see why it is now a linkedhashmap. Taher Alkhateeb On Jun 8, 2015 5:52 PM, "Adrian Crum" <[hidden email]> wrote: > This commit does not make sense and it is unnecessary. Please revert it. > > Adrian Crum > Sandglass Software > www.sandglass-software.com > > On 6/7/2015 9:03 AM, [hidden email] wrote: > >> Author: jleroux >> Date: Sun Jun 7 16:03:04 2015 >> New Revision: 1684042 >> >> URL: http://svn.apache.org/r1684042 >> Log: >> A patch from Taher Alkhateeb "Upgrade OFBiz to Java JDK 8" >> https://issues.apache.org/jira/browse/OFBIZ-6458 >> 1st step: fixes a test which was not passing >> >> Modified: >> ofbiz/trunk/framework/base/src/org/ofbiz/base/util/StringUtil.java >> >> Modified: >> ofbiz/trunk/framework/base/src/org/ofbiz/base/util/StringUtil.java >> URL: >> http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/StringUtil.java?rev=1684042&r1=1684041&r2=1684042&view=diff >> >> ============================================================================== >> --- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/StringUtil.java >> (original) >> +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/StringUtil.java >> Sun Jun 7 16:03:04 2015 >> @@ -24,6 +24,7 @@ import java.net.URLEncoder; >> import java.util.Collection; >> import java.util.HashMap; >> import java.util.Iterator; >> +import java.util.LinkedHashMap; >> import java.util.LinkedHashSet; >> import java.util.LinkedList; >> import java.util.List; >> @@ -48,7 +49,7 @@ public class StringUtil { >> protected static final Map<String, Pattern> substitutionPatternMap; >> >> static { >> - substitutionPatternMap = new HashMap<String, Pattern>(); >> + substitutionPatternMap = new LinkedHashMap<String, Pattern>(); >> substitutionPatternMap.put("&&", Pattern.compile("@and", >> Pattern.LITERAL)); >> substitutionPatternMap.put("||", Pattern.compile("@or", >> Pattern.LITERAL)); >> substitutionPatternMap.put("<=", Pattern.compile("@lteq", >> Pattern.LITERAL)); >> >> >> |
By replacing HashMap with LinkedHashMap, you are hiding the real
problem. The algorithm should not depend on insertion order, so there is a bug that needs to be fixed. Adrian Crum Sandglass Software www.sandglass-software.com On 6/8/2015 7:58 AM, Taher Alkhateeb wrote: > Hi Adrian, > > In JDK 8 the HashMap does not respect order of insertion. I explained this > bug earlier in detail. Please take a look at what i wrote and you will see > why it is now a linkedhashmap. > > Taher Alkhateeb > On Jun 8, 2015 5:52 PM, "Adrian Crum" <[hidden email]> > wrote: > >> This commit does not make sense and it is unnecessary. Please revert it. >> >> Adrian Crum >> Sandglass Software >> www.sandglass-software.com >> >> On 6/7/2015 9:03 AM, [hidden email] wrote: >> >>> Author: jleroux >>> Date: Sun Jun 7 16:03:04 2015 >>> New Revision: 1684042 >>> >>> URL: http://svn.apache.org/r1684042 >>> Log: >>> A patch from Taher Alkhateeb "Upgrade OFBiz to Java JDK 8" >>> https://issues.apache.org/jira/browse/OFBIZ-6458 >>> 1st step: fixes a test which was not passing >>> >>> Modified: >>> ofbiz/trunk/framework/base/src/org/ofbiz/base/util/StringUtil.java >>> >>> Modified: >>> ofbiz/trunk/framework/base/src/org/ofbiz/base/util/StringUtil.java >>> URL: >>> http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/StringUtil.java?rev=1684042&r1=1684041&r2=1684042&view=diff >>> >>> ============================================================================== >>> --- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/StringUtil.java >>> (original) >>> +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/StringUtil.java >>> Sun Jun 7 16:03:04 2015 >>> @@ -24,6 +24,7 @@ import java.net.URLEncoder; >>> import java.util.Collection; >>> import java.util.HashMap; >>> import java.util.Iterator; >>> +import java.util.LinkedHashMap; >>> import java.util.LinkedHashSet; >>> import java.util.LinkedList; >>> import java.util.List; >>> @@ -48,7 +49,7 @@ public class StringUtil { >>> protected static final Map<String, Pattern> substitutionPatternMap; >>> >>> static { >>> - substitutionPatternMap = new HashMap<String, Pattern>(); >>> + substitutionPatternMap = new LinkedHashMap<String, Pattern>(); >>> substitutionPatternMap.put("&&", Pattern.compile("@and", >>> Pattern.LITERAL)); >>> substitutionPatternMap.put("||", Pattern.compile("@or", >>> Pattern.LITERAL)); >>> substitutionPatternMap.put("<=", Pattern.compile("@lteq", >>> Pattern.LITERAL)); >>> >>> >>> > |
Hi Adrian,
The bug is that the pattern @gteq and @gt yield different results depending on which one gets executed first. If you execute the @gt matcher on @gteq you get a result of >eq instead of >=. So in order not to care for the insertion order then the whole algorithm and test need to be written differently and should care for matching whitespace after each pattern. Either way we cannot upgrade to JDK 8 without handling it. What do you advice as the next action? Taher Alkhateeb On Jun 8, 2015 6:07 PM, "Adrian Crum" <[hidden email]> wrote: > By replacing HashMap with LinkedHashMap, you are hiding the real problem. > The algorithm should not depend on insertion order, so there is a bug that > needs to be fixed. > > Adrian Crum > Sandglass Software > www.sandglass-software.com > > On 6/8/2015 7:58 AM, Taher Alkhateeb wrote: > >> Hi Adrian, >> >> In JDK 8 the HashMap does not respect order of insertion. I explained this >> bug earlier in detail. Please take a look at what i wrote and you will see >> why it is now a linkedhashmap. >> >> Taher Alkhateeb >> On Jun 8, 2015 5:52 PM, "Adrian Crum" <[hidden email] >> > >> wrote: >> >> This commit does not make sense and it is unnecessary. Please revert it. >>> >>> Adrian Crum >>> Sandglass Software >>> www.sandglass-software.com >>> >>> On 6/7/2015 9:03 AM, [hidden email] wrote: >>> >>> Author: jleroux >>>> Date: Sun Jun 7 16:03:04 2015 >>>> New Revision: 1684042 >>>> >>>> URL: http://svn.apache.org/r1684042 >>>> Log: >>>> A patch from Taher Alkhateeb "Upgrade OFBiz to Java JDK 8" >>>> https://issues.apache.org/jira/browse/OFBIZ-6458 >>>> 1st step: fixes a test which was not passing >>>> >>>> Modified: >>>> ofbiz/trunk/framework/base/src/org/ofbiz/base/util/StringUtil.java >>>> >>>> Modified: >>>> ofbiz/trunk/framework/base/src/org/ofbiz/base/util/StringUtil.java >>>> URL: >>>> >>>> http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/StringUtil.java?rev=1684042&r1=1684041&r2=1684042&view=diff >>>> >>>> >>>> ============================================================================== >>>> --- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/StringUtil.java >>>> (original) >>>> +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/StringUtil.java >>>> Sun Jun 7 16:03:04 2015 >>>> @@ -24,6 +24,7 @@ import java.net.URLEncoder; >>>> import java.util.Collection; >>>> import java.util.HashMap; >>>> import java.util.Iterator; >>>> +import java.util.LinkedHashMap; >>>> import java.util.LinkedHashSet; >>>> import java.util.LinkedList; >>>> import java.util.List; >>>> @@ -48,7 +49,7 @@ public class StringUtil { >>>> protected static final Map<String, Pattern> >>>> substitutionPatternMap; >>>> >>>> static { >>>> - substitutionPatternMap = new HashMap<String, Pattern>(); >>>> + substitutionPatternMap = new LinkedHashMap<String, Pattern>(); >>>> substitutionPatternMap.put("&&", Pattern.compile("@and", >>>> Pattern.LITERAL)); >>>> substitutionPatternMap.put("||", Pattern.compile("@or", >>>> Pattern.LITERAL)); >>>> substitutionPatternMap.put("<=", Pattern.compile("@lteq", >>>> Pattern.LITERAL)); >>>> >>>> >>>> >>>> >> |
Redesign the method.
Adrian Crum Sandglass Software www.sandglass-software.com On 6/8/2015 8:15 AM, Taher Alkhateeb wrote: > Hi Adrian, > > The bug is that the pattern @gteq and @gt yield different results depending > on which one gets executed first. If you execute the @gt matcher on @gteq > you get a result of >eq instead of >=. > > So in order not to care for the insertion order then the whole algorithm > and test need to be written differently and should care for matching > whitespace after each pattern. Either way we cannot upgrade to JDK 8 > without handling it. What do you advice as the next action? > > Taher Alkhateeb > On Jun 8, 2015 6:07 PM, "Adrian Crum" <[hidden email]> > wrote: > >> By replacing HashMap with LinkedHashMap, you are hiding the real problem. >> The algorithm should not depend on insertion order, so there is a bug that >> needs to be fixed. >> >> Adrian Crum >> Sandglass Software >> www.sandglass-software.com >> >> On 6/8/2015 7:58 AM, Taher Alkhateeb wrote: >> >>> Hi Adrian, >>> >>> In JDK 8 the HashMap does not respect order of insertion. I explained this >>> bug earlier in detail. Please take a look at what i wrote and you will see >>> why it is now a linkedhashmap. >>> >>> Taher Alkhateeb >>> On Jun 8, 2015 5:52 PM, "Adrian Crum" <[hidden email] >>>> >>> wrote: >>> >>> This commit does not make sense and it is unnecessary. Please revert it. >>>> >>>> Adrian Crum >>>> Sandglass Software >>>> www.sandglass-software.com >>>> >>>> On 6/7/2015 9:03 AM, [hidden email] wrote: >>>> >>>> Author: jleroux >>>>> Date: Sun Jun 7 16:03:04 2015 >>>>> New Revision: 1684042 >>>>> >>>>> URL: http://svn.apache.org/r1684042 >>>>> Log: >>>>> A patch from Taher Alkhateeb "Upgrade OFBiz to Java JDK 8" >>>>> https://issues.apache.org/jira/browse/OFBIZ-6458 >>>>> 1st step: fixes a test which was not passing >>>>> >>>>> Modified: >>>>> ofbiz/trunk/framework/base/src/org/ofbiz/base/util/StringUtil.java >>>>> >>>>> Modified: >>>>> ofbiz/trunk/framework/base/src/org/ofbiz/base/util/StringUtil.java >>>>> URL: >>>>> >>>>> http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/StringUtil.java?rev=1684042&r1=1684041&r2=1684042&view=diff >>>>> >>>>> >>>>> ============================================================================== >>>>> --- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/StringUtil.java >>>>> (original) >>>>> +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/StringUtil.java >>>>> Sun Jun 7 16:03:04 2015 >>>>> @@ -24,6 +24,7 @@ import java.net.URLEncoder; >>>>> import java.util.Collection; >>>>> import java.util.HashMap; >>>>> import java.util.Iterator; >>>>> +import java.util.LinkedHashMap; >>>>> import java.util.LinkedHashSet; >>>>> import java.util.LinkedList; >>>>> import java.util.List; >>>>> @@ -48,7 +49,7 @@ public class StringUtil { >>>>> protected static final Map<String, Pattern> >>>>> substitutionPatternMap; >>>>> >>>>> static { >>>>> - substitutionPatternMap = new HashMap<String, Pattern>(); >>>>> + substitutionPatternMap = new LinkedHashMap<String, Pattern>(); >>>>> substitutionPatternMap.put("&&", Pattern.compile("@and", >>>>> Pattern.LITERAL)); >>>>> substitutionPatternMap.put("||", Pattern.compile("@or", >>>>> Pattern.LITERAL)); >>>>> substitutionPatternMap.put("<=", Pattern.compile("@lteq", >>>>> Pattern.LITERAL)); >>>>> >>>>> >>>>> >>>>> >>> > |
I just spent some time looking at this, and I have come to the
conclusion that a rewrite will take too much work. The LinkedHashMap replacement is fine. Adrian Crum Sandglass Software www.sandglass-software.com On 6/8/2015 8:24 AM, Adrian Crum wrote: > Redesign the method. > > Adrian Crum > Sandglass Software > www.sandglass-software.com > > On 6/8/2015 8:15 AM, Taher Alkhateeb wrote: >> Hi Adrian, >> >> The bug is that the pattern @gteq and @gt yield different results >> depending >> on which one gets executed first. If you execute the @gt matcher on @gteq >> you get a result of >eq instead of >=. >> >> So in order not to care for the insertion order then the whole algorithm >> and test need to be written differently and should care for matching >> whitespace after each pattern. Either way we cannot upgrade to JDK 8 >> without handling it. What do you advice as the next action? >> >> Taher Alkhateeb >> On Jun 8, 2015 6:07 PM, "Adrian Crum" >> <[hidden email]> >> wrote: >> >>> By replacing HashMap with LinkedHashMap, you are hiding the real >>> problem. >>> The algorithm should not depend on insertion order, so there is a bug >>> that >>> needs to be fixed. >>> >>> Adrian Crum >>> Sandglass Software >>> www.sandglass-software.com >>> >>> On 6/8/2015 7:58 AM, Taher Alkhateeb wrote: >>> >>>> Hi Adrian, >>>> >>>> In JDK 8 the HashMap does not respect order of insertion. I >>>> explained this >>>> bug earlier in detail. Please take a look at what i wrote and you >>>> will see >>>> why it is now a linkedhashmap. >>>> >>>> Taher Alkhateeb >>>> On Jun 8, 2015 5:52 PM, "Adrian Crum" >>>> <[hidden email] >>>>> >>>> wrote: >>>> >>>> This commit does not make sense and it is unnecessary. Please >>>> revert it. >>>>> >>>>> Adrian Crum >>>>> Sandglass Software >>>>> www.sandglass-software.com >>>>> >>>>> On 6/7/2015 9:03 AM, [hidden email] wrote: >>>>> >>>>> Author: jleroux >>>>>> Date: Sun Jun 7 16:03:04 2015 >>>>>> New Revision: 1684042 >>>>>> >>>>>> URL: http://svn.apache.org/r1684042 >>>>>> Log: >>>>>> A patch from Taher Alkhateeb "Upgrade OFBiz to Java JDK 8" >>>>>> https://issues.apache.org/jira/browse/OFBIZ-6458 >>>>>> 1st step: fixes a test which was not passing >>>>>> >>>>>> Modified: >>>>>> >>>>>> ofbiz/trunk/framework/base/src/org/ofbiz/base/util/StringUtil.java >>>>>> >>>>>> Modified: >>>>>> ofbiz/trunk/framework/base/src/org/ofbiz/base/util/StringUtil.java >>>>>> URL: >>>>>> >>>>>> http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/StringUtil.java?rev=1684042&r1=1684041&r2=1684042&view=diff >>>>>> >>>>>> >>>>>> >>>>>> ============================================================================== >>>>>> >>>>>> --- >>>>>> ofbiz/trunk/framework/base/src/org/ofbiz/base/util/StringUtil.java >>>>>> (original) >>>>>> +++ >>>>>> ofbiz/trunk/framework/base/src/org/ofbiz/base/util/StringUtil.java >>>>>> Sun Jun 7 16:03:04 2015 >>>>>> @@ -24,6 +24,7 @@ import java.net.URLEncoder; >>>>>> import java.util.Collection; >>>>>> import java.util.HashMap; >>>>>> import java.util.Iterator; >>>>>> +import java.util.LinkedHashMap; >>>>>> import java.util.LinkedHashSet; >>>>>> import java.util.LinkedList; >>>>>> import java.util.List; >>>>>> @@ -48,7 +49,7 @@ public class StringUtil { >>>>>> protected static final Map<String, Pattern> >>>>>> substitutionPatternMap; >>>>>> >>>>>> static { >>>>>> - substitutionPatternMap = new HashMap<String, Pattern>(); >>>>>> + substitutionPatternMap = new LinkedHashMap<String, >>>>>> Pattern>(); >>>>>> substitutionPatternMap.put("&&", Pattern.compile("@and", >>>>>> Pattern.LITERAL)); >>>>>> substitutionPatternMap.put("||", Pattern.compile("@or", >>>>>> Pattern.LITERAL)); >>>>>> substitutionPatternMap.put("<=", Pattern.compile("@lteq", >>>>>> Pattern.LITERAL)); >>>>>> >>>>>> >>>>>> >>>>>> >>>> >> |
In reply to this post by taher
For the record, HashMap has never had a guaranteed iteration order. This
has less to do with Java 8 and more to do with the switch from FastMap (which provided insertion-order iteration) to HashMap (which does not). Regards Scott On 9 June 2015 at 02:58, Taher Alkhateeb <[hidden email]> wrote: > Hi Adrian, > > In JDK 8 the HashMap does not respect order of insertion. I explained this > bug earlier in detail. Please take a look at what i wrote and you will see > why it is now a linkedhashmap. > > Taher Alkhateeb > On Jun 8, 2015 5:52 PM, "Adrian Crum" <[hidden email]> > wrote: > > > This commit does not make sense and it is unnecessary. Please revert it. > > > > Adrian Crum > > Sandglass Software > > www.sandglass-software.com > > > > On 6/7/2015 9:03 AM, [hidden email] wrote: > > > >> Author: jleroux > >> Date: Sun Jun 7 16:03:04 2015 > >> New Revision: 1684042 > >> > >> URL: http://svn.apache.org/r1684042 > >> Log: > >> A patch from Taher Alkhateeb "Upgrade OFBiz to Java JDK 8" > >> https://issues.apache.org/jira/browse/OFBIZ-6458 > >> 1st step: fixes a test which was not passing > >> > >> Modified: > >> ofbiz/trunk/framework/base/src/org/ofbiz/base/util/StringUtil.java > >> > >> Modified: > >> ofbiz/trunk/framework/base/src/org/ofbiz/base/util/StringUtil.java > >> URL: > >> > http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/StringUtil.java?rev=1684042&r1=1684041&r2=1684042&view=diff > >> > >> > ============================================================================== > >> --- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/StringUtil.java > >> (original) > >> +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/StringUtil.java > >> Sun Jun 7 16:03:04 2015 > >> @@ -24,6 +24,7 @@ import java.net.URLEncoder; > >> import java.util.Collection; > >> import java.util.HashMap; > >> import java.util.Iterator; > >> +import java.util.LinkedHashMap; > >> import java.util.LinkedHashSet; > >> import java.util.LinkedList; > >> import java.util.List; > >> @@ -48,7 +49,7 @@ public class StringUtil { > >> protected static final Map<String, Pattern> > substitutionPatternMap; > >> > >> static { > >> - substitutionPatternMap = new HashMap<String, Pattern>(); > >> + substitutionPatternMap = new LinkedHashMap<String, Pattern>(); > >> substitutionPatternMap.put("&&", Pattern.compile("@and", > >> Pattern.LITERAL)); > >> substitutionPatternMap.put("||", Pattern.compile("@or", > >> Pattern.LITERAL)); > >> substitutionPatternMap.put("<=", Pattern.compile("@lteq", > >> Pattern.LITERAL)); > >> > >> > >> > |
Free forum by Nabble | Edit this page |