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

UriTemplate COMPOSITE_PREFIXES init problem #117

Closed
wonderfly opened this issue Jan 9, 2015 · 4 comments

Comments

@wonderfly
Copy link
Contributor

commented Jan 9, 2015

From willem.s...@gmail.com on May 19, 2012 09:57:13

Version of google-http-java-client: 1.9.0-beta
Java environment: Java 6

There is a dangerous initialization problem in the class
com.google.api.client.http.UriTemplate. The COMPOSITE_PREFIXES map is not filled after classloading but only when the enum CompositeOutput is used. This means the first time getCompositeOutput is called, the map is still empty and only on line 190 the map is filled.

Testcase:

Map<String, Object> map = new HashMap<String, Object>();
map.put("id", Arrays.asList("a", "b", "c").iterator());

System.out.println("first:" + UriTemplate.expand("{/id_}", map, false));
System.out.println("second:" + UriTemplate.expand("{/id_}", map, false));

Output:
first:
second:/a/b/c How would you expect it to be fixed? Initialize map in a static {} block
The result of calling UriTemplate.expand twice should be the same

Original issue: http://code.google.com/p/google-http-java-client/issues/detail?id=117

@wonderfly

This comment has been minimized.

Copy link
Contributor Author

commented Jan 9, 2015

From rmis...@google.com on May 21, 2012 04:17:03

Thank you for reporting this issue!

Labels: -Priority-Medium Priority-High Milestone-Version1.10.0

@wonderfly wonderfly self-assigned this Jan 9, 2015

@wonderfly

This comment has been minimized.

Copy link
Contributor Author

commented Jan 9, 2015

From rmis...@google.com on May 21, 2012 07:25:08

http://codereview.appspot.com/6208085/

Status: Started

@wonderfly

This comment has been minimized.

Copy link
Contributor Author

commented Jan 9, 2015

From rmis...@google.com on May 21, 2012 09:29:17

Labels: Component-HTTP

@wonderfly

This comment has been minimized.

Copy link
Contributor Author

commented Jan 9, 2015

From rmis...@google.com on May 22, 2012 13:30:38

Status: Fixed

@wonderfly wonderfly closed this Jan 9, 2015

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