Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StringUtils.commaDelimitedListToSet and removeDuplicateStrings should preserve original order [SPR-12003] #16619

Closed
spring-issuemaster opened this issue Jul 16, 2014 · 6 comments

Comments

Projects
None yet
2 participants
@spring-issuemaster
Copy link
Collaborator

commented Jul 16, 2014

Phil Webb opened SPR-12003 and commented

As noticed by Gary Russell, StringUtils.commaDelimitedListToSet uses a TreeSet which will sort results. A LinkedHashSet might be a better option,

spring-projects/spring-boot@aa38d33#commitcomment-7017880


Affects: 4.0.6

Referenced from: commits 783cb2c

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Apr 17, 2015

Amey Jadiye commented

My two cents towards improvements, as the sorting is extra and not necessary computation towards the output, we should use LinkedHashSet. Performance of LinkedHashSet is always better than TreeSet :)

Here is PR for fix, #778

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Apr 17, 2015

Amey Jadiye commented

well, not only commaDelimitedListToSet, there are many more methods which need to replace the Treeset in same File. Should raise another ticket for that task

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Apr 24, 2015

Juergen Hoeller commented

I'm afraid we can't easily change StringUtils.commaDelimitedListToSet since it is even documented to return a TreeSet; I'm rather considering to deprecate it altogether. Preferably, use StringUtils.commaDelimitedListToStringArray instead which does preserve the original order...

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Apr 28, 2015

Amey Jadiye commented

Well, i'm disagree with deprecating the method, thinking with programmers perspective i still need the method which returns the Collection(Set) and not Array for sake of ease in programming.

Isssue mention in ticket is the performace hamper with the use of TreeSet which we can resolve simply replacing with LinkedHashSet.

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented May 7, 2015

Juergen Hoeller commented

Alright, let's keep it, turn it to LinkedHashSet, and see how it goes during the 4.2 RC phase.

Juergen

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented May 7, 2015

Amey Jadiye commented

@jhoeller PR is already made against master, hope thats correct, please accept PR, #778

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.