Issue
request.getRequestUri() returns a String.
request.getRequestURL() returns a StringBuffer.
I can understand the reason that Requests.Util's requestURL() use StringBuffer for making String.
However, I can't understand why that method return StringBuffer not String.
Why..?
Solution
The JavaDoc of that method says
Because this method returns a
StringBuffer
, not a string, you can modify the URL easily, for example, to append query parameters.
This seems to be their motivation for this specific type.
Personally I don't think this kind of micro-optimization is worth the headache. Especially since StringBuffer
has been all but replaced by StringBuilder
.
Answered By - Joachim Sauer