FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Add support for connection timeouts by stadlerj · Pull Request #19 · webex/webex-java-sdk · GitHub

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

Filter by extension

Filter by extension .java  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
17 changes: 17 additions & 0 deletions src/main/java/com/ciscospark/Client.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,14 @@ class Client {
final String clientId;
final String clientSecret;
final Logger logger;
final private Integer connectTimeout;
final private Integer readTimeout;

Client(URI baseUri, String authCode, URI redirectUri, String accessToken, String refreshToken, String clientId, String clientSecret, Logger logger) {
this(baseUri, authCode, redirectUri, accessToken, refreshToken, clientId, clientSecret, logger, null, null);
}

Client(URI baseUri, String authCode, URI redirectUri, String accessToken, String refreshToken, String clientId, String clientSecret, Logger logger, Integer connectTimeout, Integer readTimeout) {
this.authCode = authCode;
this.redirectUri = redirectUri;
this.baseUri = baseUri;
Expand All @@ -45,6 +51,8 @@ class Client {
this.clientId = clientId;
this.clientSecret = clientSecret;
this.logger = logger;
this.connectTimeout = connectTimeout;
this.readTimeout = readTimeout;
}

<T> T post(Class<T> clazz, String path, T body) {
Expand Down Expand Up @@ -320,6 +328,15 @@ private HttpURLConnection getConnection(URL url) throws IOException {
connection.setRequestProperty("Authorization", authorization);
}
connection.setRequestProperty(TRACKING_ID, UUID.randomUUID().toString());

if(connectTimeout != null) {
connection.setConnectTimeout(connectTimeout);
}

if(readTimeout != null) {
connection.setReadTimeout(readTimeout);
}

return connection;
}

Expand Down
15 changes: 14 additions & 1 deletion src/main/java/com/ciscospark/Spark.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,25 @@ public static class Builder {
private String clientSecret;
private Logger logger;
private URI baseUrl = URI.create("https://api.ciscospark.com/v1");
private Integer connectTimeout;
private Integer readTimeout;


public Builder baseUrl(URI uri) {
this.baseUrl = uri;
return this;
}

public Builder connectTimeout(Integer connectTimeout) {
this.connectTimeout = connectTimeout;
return this;
}

public Builder readTimeout(Integer readTimeout) {
this.readTimeout = readTimeout;
return this;
}

public Builder redirectUri(URI uri) {
this.redirectUri = uri;
return this;
Expand Down Expand Up @@ -73,7 +86,7 @@ public Builder logger(Logger logger) {
}

public Spark build() {
return new SparkImpl(new Client(baseUrl, authCode, redirectUri, accessToken, refreshToken, clientId, clientSecret, logger));
return new SparkImpl(new Client(baseUrl, authCode, redirectUri, accessToken, refreshToken, clientId, clientSecret, logger, connectTimeout, readTimeout));
}
}

Expand Down

Back | FazBrowse Home | New Git URL