Description
RequestBuilder.build() already builds a URI for validation, and Request.getUrl() constructs a new URI on each getUrl() call. URI objects are immutable, and provide a stronger type guarantee than just using String.
While profiling a high performance application, 500 outbound HTTP requests through a proxy resulted in ~4,000 invocations of URI.create(String). This overhead took roughly 2% of our response time and is highlighted as a Hot spot in Yourkit.
"Name","Time (ms)","Invocation Count","Level"
"java.net.URI.create(String)","3396","4005", "1"
"com.ning.http.client.RequestBuilderBase$RequestImpl.toUrl(boolean)","1851","2505", "2"
"com.ning.http.util.AsyncHttpProviderUtils.createUri(String)","544","500", "2"
"com.ning.http.util.ProxyUtils.avoidProxy(ProxyServer, Request)","542","500", "2"
"com.ning.http.client.RequestBuilderBase.buildUrl(String)","457","500", "2"