Skip to content
This repository was archived by the owner on Sep 26, 2023. It is now read-only.

Commit 8f48b70

Browse files
authored
fix: fix httpjson executor (#1448)
1 parent 209b494 commit 8f48b70

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

‎gax-httpjson/src/main/java/com/google/api/gax/httpjson/ManagedHttpJsonChannel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public static class Builder {
153153
private Builder() {}
154154

155155
public Builder setExecutor(Executor executor) {
156-
this.executor = Preconditions.checkNotNull(executor);
156+
this.executor = executor == null ? DEFAULT_EXECUTOR : executor;
157157
return this;
158158
}
159159

‎gax-httpjson/src/test/java/com/google/api/gax/httpjson/InstantiatingHttpJsonChannelProviderTest.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@ public void basicTest() throws IOException {
6262
provider = provider.withEndpoint(endpoint);
6363
assertThat(provider.needsEndpoint()).isFalse();
6464

65+
assertThat(provider.needsHeaders()).isTrue();
66+
provider = provider.withHeaders(Collections.<String, String>emptyMap());
67+
assertThat(provider.needsHeaders()).isFalse();
68+
69+
// Make sure getTransportChannel works without setting executor
70+
assertThat(provider.getTransportChannel()).isInstanceOf(HttpJsonTransportChannel.class);
71+
6572
assertThat(provider.needsExecutor()).isTrue();
6673
provider = provider.withExecutor((Executor) executor);
6774
assertThat(provider.needsExecutor()).isFalse();
@@ -71,10 +78,6 @@ public void basicTest() throws IOException {
7178
provider = provider.withExecutor(executor);
7279
assertThat(provider.needsExecutor()).isFalse();
7380

74-
assertThat(provider.needsHeaders()).isTrue();
75-
provider = provider.withHeaders(Collections.<String, String>emptyMap());
76-
assertThat(provider.needsHeaders()).isFalse();
77-
7881
assertThat(provider.acceptsPoolSize()).isFalse();
7982
Exception thrownException = null;
8083
try {

0 commit comments

Comments
 (0)