Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public class HttpCall {
private static final String ADMIN_PASSWORD = "admin";

private static final String DEFAULT_USER_AGENT = "Orchestrator";
private static final String CANNOT_CALL_FORMAT = CANNOT_CALL_FORMAT;

private final OkHttpClient okClient;
private final HttpUrl baseUrl;
Expand Down Expand Up @@ -141,9 +142,8 @@ public HttpCall setParam(String key, @Nullable String value) {
public HttpCall setParams(String key1, @Nullable String value1, String... otherKeysAndNames) {
checkArgument(otherKeysAndNames.length % 2 == 0, "Expecting even number of arguments: %s", Arrays.toString(otherKeysAndNames));
parameters.put(key1, value1);
for (int i = 0; i < otherKeysAndNames.length; i++) {
for (int i = 0; i < otherKeysAndNames.length; i += 2) {
parameters.put(otherKeysAndNames[i], otherKeysAndNames[i + 1]);
i++;
}
return this;
}
Expand Down Expand Up @@ -196,10 +196,10 @@ public void downloadToFile(File file) {
try {
doDownloadToFile(okRequest, file);
} catch (IOException e2) {
throw new IllegalStateException(format("Can not call %s", okRequest.url()), e2);
throw new IllegalStateException(format(CANNOT_CALL_FORMAT, okRequest.url()), e2);
}
} catch (IOException e) {
throw new IllegalStateException(format("Can not call %s", okRequest.url()), e);
throw new IllegalStateException(format(CANNOT_CALL_FORMAT, okRequest.url()), e);
}
}

Expand All @@ -221,10 +221,10 @@ public File downloadToDirectory(File dir) {
try {
return doDownloadToDirectory(dir, okRequest);
} catch (IOException e2) {
throw new IllegalStateException(format("Can not call %s", okRequest.url()), e2);
throw new IllegalStateException(format(CANNOT_CALL_FORMAT, okRequest.url()), e2);
}
} catch (IOException e) {
throw new IllegalStateException(format("Can not call %s", okRequest.url()), e);
throw new IllegalStateException(format(CANNOT_CALL_FORMAT, okRequest.url()), e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import okhttp3.Response;
import okhttp3.Route;

import javax.annotation.Nullable;

import static org.apache.commons.lang3.StringUtils.isEmpty;

public class HttpClient {
Expand Down Expand Up @@ -88,7 +90,7 @@ private ProxyAuthenticator(String login, String password) {
}

@Override
public Request authenticate(Route route, Response response) {
public Request authenticate(@Nullable Route route, Response response) {
if (HttpURLConnection.HTTP_PROXY_AUTH == response.code()) {
String credential = Credentials.basic(login, password);
return response.request().newBuilder().header("Proxy-Authorization", credential).build();
Expand Down