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

Spring RestTemplate adds extra [] (square brackets) when sending arrays [SPR-16425] #20971

Closed
spring-projects-issues opened this issue Jan 27, 2018 · 4 comments
Assignees
Labels
in: web status: declined type: enhancement

Comments

@spring-projects-issues
Copy link
Collaborator

@spring-projects-issues spring-projects-issues commented Jan 27, 2018

Artem Loginov opened SPR-16425 and commented

As described on StackOverflow there is an issue serializing array with RestTemplate. The work around was suggested, but I can't use it in my current project because code with rest template is generated by swagger.
The pull request is attached.
I am not sure about the performance of this fix since I am new to Java. But I will appreciate any help and comments so I can improve this solution to make it production ready.


Affects: 5.0.2

Reference URL: https://stackoverflow.com/questions/33593390/spring-resttemplate-sending-array-list-of-string-in-get-request

Attachments:

Referenced from: pull request #1655

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Jan 27, 2018

Artem Loginov commented

I've found a draw back because space is added in between of every serialized element. It was fixed in second commit.

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Jan 29, 2018

Rossen Stoyanchev commented

Artem Loginov can you please update the description of the issue to be self-sufficient, independent of StackOverflow? In particular please provide the concrete example that you have in mind.

My concern with this is that URI variable value expansion was never meant to be a type conversion mechanism. Besides collections, there are arrays, maps, they can be nested, and so one, one can go on endlessly. While in your case evidently you don't want brackets, in other cases others might want them, and they could be relying on it today, and there would be no way to customize this. If we're going to go down that route I would rather see a ConversionService being used, e.g. in the RestTemplate.

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Feb 22, 2018

Artem Loginov commented

@Rossen Stoyanchev, Thank you for your comment. I completely agree with it. I have not thought about corner cases. But it is still not obvious that spring uses toString for some cases. I will agree on primitives, but not on collections. In any case I think this is not a bug, but just specific implementation case. So will close the issue. Feel free to write me an email or contact in any other way if you need more information.

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Feb 22, 2018

Artem Loginov commented

Actually, I can't close an issue. Could someone with permissions do it for me?

@spring-projects-issues spring-projects-issues added status: declined type: enhancement in: web labels Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web status: declined type: enhancement
Projects
None yet
Development

No branches or pull requests

2 participants