Skip to content

Commit aa0e06c

Browse files
tilgalascopybara-github
authored andcommitted
refactor: update ApiClient.createHttpClient Optional timeout param to @nullable
PiperOrigin-RevId: 881536165
1 parent 72c9804 commit aa0e06c

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

core/src/main/java/com/google/adk/sessions/ApiClient.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ abstract class ApiClient {
6767
applyHttpOptions(customHttpOptions.get());
6868
}
6969

70-
this.httpClient = createHttpClient(httpOptions.timeout());
70+
this.httpClient = createHttpClient(httpOptions.timeout().orElse(null));
7171
}
7272

7373
ApiClient(
@@ -113,13 +113,13 @@ abstract class ApiClient {
113113
}
114114
this.apiKey = Optional.empty();
115115
this.vertexAI = true;
116-
this.httpClient = createHttpClient(httpOptions.timeout());
116+
this.httpClient = createHttpClient(httpOptions.timeout().orElse(null));
117117
}
118118

119-
private OkHttpClient createHttpClient(Optional<Integer> timeout) {
119+
private OkHttpClient createHttpClient(@Nullable Integer timeout) {
120120
OkHttpClient.Builder builder = new OkHttpClient().newBuilder();
121-
if (timeout.isPresent()) {
122-
builder.connectTimeout(Duration.ofMillis(timeout.get()));
121+
if (timeout != null) {
122+
builder.connectTimeout(Duration.ofMillis(timeout));
123123
}
124124
return builder.build();
125125
}

0 commit comments

Comments
 (0)