diff --git a/gax-httpjson/src/main/java/com/google/api/gax/httpjson/ManagedHttpJsonChannel.java b/gax-httpjson/src/main/java/com/google/api/gax/httpjson/ManagedHttpJsonChannel.java index af3e9bbd7..760f3f0b1 100644 --- a/gax-httpjson/src/main/java/com/google/api/gax/httpjson/ManagedHttpJsonChannel.java +++ b/gax-httpjson/src/main/java/com/google/api/gax/httpjson/ManagedHttpJsonChannel.java @@ -153,7 +153,7 @@ public static class Builder { private Builder() {} public Builder setExecutor(Executor executor) { - this.executor = Preconditions.checkNotNull(executor); + this.executor = executor == null ? DEFAULT_EXECUTOR : executor; return this; } diff --git a/gax-httpjson/src/test/java/com/google/api/gax/httpjson/InstantiatingHttpJsonChannelProviderTest.java b/gax-httpjson/src/test/java/com/google/api/gax/httpjson/InstantiatingHttpJsonChannelProviderTest.java index bc00f164b..4061ff8ba 100644 --- a/gax-httpjson/src/test/java/com/google/api/gax/httpjson/InstantiatingHttpJsonChannelProviderTest.java +++ b/gax-httpjson/src/test/java/com/google/api/gax/httpjson/InstantiatingHttpJsonChannelProviderTest.java @@ -62,6 +62,13 @@ public void basicTest() throws IOException { provider = provider.withEndpoint(endpoint); assertThat(provider.needsEndpoint()).isFalse(); + assertThat(provider.needsHeaders()).isTrue(); + provider = provider.withHeaders(Collections.emptyMap()); + assertThat(provider.needsHeaders()).isFalse(); + + // Make sure getTransportChannel works without setting executor + assertThat(provider.getTransportChannel()).isInstanceOf(HttpJsonTransportChannel.class); + assertThat(provider.needsExecutor()).isTrue(); provider = provider.withExecutor((Executor) executor); assertThat(provider.needsExecutor()).isFalse(); @@ -71,10 +78,6 @@ public void basicTest() throws IOException { provider = provider.withExecutor(executor); assertThat(provider.needsExecutor()).isFalse(); - assertThat(provider.needsHeaders()).isTrue(); - provider = provider.withHeaders(Collections.emptyMap()); - assertThat(provider.needsHeaders()).isFalse(); - assertThat(provider.acceptsPoolSize()).isFalse(); Exception thrownException = null; try {