A SortedMap approach wouldn't preserve insertion order, but would instead re-order parameters on the fly with the comparator provided. A LinkedHashMap (or LinkedMultimap, which seems like a better solution as you suggest) preserves insertion order, so this would be the correct way to go if we're looking to preserve the parameter order.
Mat On 31 August 2010 10:23, Gagandeep singh <[email protected]> wrote: > I have a doubt. A fellow colleague tells me that we should retain the order > in which the keys are inserted into the query params map, because some ppl > do funny stuff like their own begin and end parameters and mark useful > parameters in between. > > I was wondering if we should go with a SortedMap approach for query params > instead. I mean do we really need to bother about query param P1 added > before query param P2 ? Also, tomorrow if some1 refactores some code, the > tests should not fail because the order of insertion has changed. > > As a side note, i think Google uses LinkedListMultimap for query params. > Isn't that better than LinkedHashMap<String, List<String>> ? > > Thoughts ? > > > > On Mon, Aug 30, 2010 at 1:31 PM, Gagandeep singh <[email protected]>wrote: > >> Nice debugging. >> >> >> On Mon, Aug 30, 2010 at 7:42 AM, Paul Lindner <[email protected]>wrote: >> >>> The test output showed that the problem was incorrectly ordered query >>> params. I validated that the problem occurs only on Java 1.5. Therefore >>> it >>> had to be a HashMap iteration problem somewhere. So I poked around >>> UriBuilder and found one remaining use of HashMap and replaced it with >>> LinkedHashMap. >>> >>> On Sun, Aug 29, 2010 at 6:54 PM, Gagandeep singh <[email protected] >>> >wrote: >>> >>> > Could you also tell us how you found and fixed the problem ? >>> > >>> > On Mon, Aug 30, 2010 at 7:24 AM, Gagandeep singh <[email protected] >>> > >wrote: >>> > >>> > > Thanks for fixing this Paul. >>> > > >>> > > >>> > > On Mon, Aug 30, 2010 at 2:46 AM, Apache Hudson Server < >>> > > [email protected]> wrote: >>> > > >>> > >> See <https://hudson.apache.org/hudson/job/Shindig/1793/> >>> > >> >>> > >> >>> > >> >>> > > >>> > >>> >>> >>> >>> -- >>> Paul Lindner -- [email protected] -- linkedin.com/in/plindner >>> >> >> > -- Mat Mannion Web Developer IT Services University of Warwick Coventry CV4 7AL Tel: 024 765 74433 Email: [email protected]
