Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.

Removed conflicting overloaded methods from RestTemplate #28

Merged
merged 1 commit into from
Jul 29, 2013

Conversation

ramnivas
Copy link
Contributor

RestTemplate consisted of methods of the following form (getFor..., postFor..., etc.)
def m(...)
and
def m(..., uriVariables: Any*)

This made it impossible to call methods without passing any uriVariables, since the compiler cannot determine which of the overloaded method is intended. In any case, there is no need for the non-varargs methods; users can just call the varargs version passing no arguments for the uriVariables parameter.

RestTemplate consisted of methods of the following form (getFor..., postFor..., etc.)
    def m(...)
and
    def m(..., uriVariables: Any*)

This made it impossible to call methods without passing any uriVariables, since the compiler cannot determine which of the overloaded method is intended. In any case, there is no need for the non-varargs methods; users can just call the varargs version passing no arguments for the uriVariables parameter.
poutsma pushed a commit that referenced this pull request Jul 29, 2013
Removed conflicting overloaded methods from RestTemplate
@poutsma poutsma merged commit e3586d8 into spring-attic:master Jul 29, 2013
@poutsma
Copy link

poutsma commented Jul 29, 2013

Merged, thanks!

poutsma pushed a commit that referenced this pull request Jul 29, 2013
This reverts commit e3586d8, reversing
changes made to fbfc885.
@poutsma
Copy link

poutsma commented Jul 29, 2013

After taking a closer look, I decided to revert this pull request, at least for the time being.

Indeed, there are three methods for each variant in the RestTemplate:

  • m(url: String, uriVariables: Any*)
  • m(url: String, uriVariables: Map[String, _])
  • m(url: URI)

But note that the last variant uses a java.net.URI, not a String. This is the variant that does not do any variable substitution, and more importantly no URI encoding, whereas the other two do. The lack of URI encoding is the reason this variant exists: it can be pretty hard (i.e. impossible) to correctly encode a URI given just a plain text string, since all components that make up the URI have different encoding requirements (see UriComponentsBuilder in Spring). Having a (already encoded) URI object as a parameter fixes this problem.

Now, going back to the issue that instigated this pull request: I am not sure what compiler problems you experienced, but removing the URI variants is not a good solution, for the reasons given above. Can you perhaps show me a snippet of code that illustrates the problem?

wodzuu pushed a commit to wodzuu/spring-scala that referenced this pull request Aug 1, 2013
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants