|
3 | 3 | import java.io.IOException; |
4 | 4 | import java.io.OutputStream; |
5 | 5 | import java.lang.reflect.Type; |
| 6 | +import java.net.MalformedURLException; |
| 7 | +import java.net.URL; |
6 | 8 | import java.time.Duration; |
7 | 9 | import java.util.concurrent.Callable; |
8 | 10 | import java.util.concurrent.Executors; |
@@ -105,10 +107,6 @@ private HttpRequestFactory createRequestFactory() { |
105 | 107 | }); |
106 | 108 | } |
107 | 109 |
|
108 | | - public String getBaseUrl() { |
109 | | - return this.config.getBaseUrl(); |
110 | | - } |
111 | | - |
112 | 110 | public ListenableFuture<?> get(String path, HttpOption... options) { |
113 | 111 | return get(path, (TypeToken) null, options); |
114 | 112 | } |
@@ -166,11 +164,17 @@ protected ListenableFuture<?> request(String method, String path, @Nullable Obje |
166 | 164 | } |
167 | 165 |
|
168 | 166 | protected <T> ListenableFuture<T> request(String method, String path, @Nullable Object content, @Nullable TypeToken<T> returnType, HttpOption...options) { |
| 167 | + final GenericUrl url; |
| 168 | + try { |
| 169 | + url = new GenericUrl(new URL(config.getBaseUrl(), path)); |
| 170 | + } catch(MalformedURLException e) { |
| 171 | + throw new IllegalArgumentException(e.getMessage()); |
| 172 | + } |
| 173 | + |
169 | 174 | // NOTE: Serialization must happen synchronously, because getter methods may not be thread-safe |
170 | 175 | final HttpContent httpContent = content == null ? null : new Content(gson.toJson(content)); |
171 | 176 |
|
172 | | - GenericUrl url = new GenericUrl(this.getBaseUrl() + path); |
173 | | - HttpRequest request; |
| 177 | + final HttpRequest request; |
174 | 178 | try { |
175 | 179 | request = requestFactory.buildRequest(method, url, httpContent).setThrowExceptionOnExecuteError(false); |
176 | 180 | } catch (IOException e) { |
|
0 commit comments