From d4668579ef09f217ea9de47f21fafc820166173c Mon Sep 17 00:00:00 2001 From: Idel Pivnitskiy Date: Wed, 12 Aug 2020 10:06:24 -0700 Subject: [PATCH] Add missed overrides for the client builders (#1117) Motivation: Some methods are not overridden in `BaseSingleAddressHttpClientBuilder` and `MultiAddressHttpClientBuilder`. Users have to cast if they use those missed methods on this builders. Modifications: - Add overrides for `BaseSingleAddressHttpClientBuilder`: `executionStrategy` and `appendClientFilter`; - Add overrides for `MultiAddressHttpClientBuilder.java`: `protocols`; Result: Users can use fluent builder API without need to cast builder types. --- .../api/BaseSingleAddressHttpClientBuilder.java | 13 +++++++++++++ .../http/api/MultiAddressHttpClientBuilder.java | 7 ++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/servicetalk-http-api/src/main/java/io/servicetalk/http/api/BaseSingleAddressHttpClientBuilder.java b/servicetalk-http-api/src/main/java/io/servicetalk/http/api/BaseSingleAddressHttpClientBuilder.java index d7401dd7c6..23f1a575e2 100644 --- a/servicetalk-http-api/src/main/java/io/servicetalk/http/api/BaseSingleAddressHttpClientBuilder.java +++ b/servicetalk-http-api/src/main/java/io/servicetalk/http/api/BaseSingleAddressHttpClientBuilder.java @@ -32,6 +32,9 @@ abstract class BaseSingleAddressHttpClientBuilder ioExecutor(IoExecutor ioExecutor); + @Override + public abstract BaseSingleAddressHttpClientBuilder executionStrategy(HttpExecutionStrategy strategy); + @Override public abstract BaseSingleAddressHttpClientBuilder bufferAllocator(BufferAllocator allocator); @@ -59,6 +62,16 @@ public BaseSingleAddressHttpClientBuilder appendConnectionFilter( public abstract BaseSingleAddressHttpClientBuilder appendConnectionFactoryFilter( ConnectionFactoryFilter factory); + @Override + public abstract BaseSingleAddressHttpClientBuilder appendClientFilter( + StreamingHttpClientFilterFactory factory); + + @Override + public BaseSingleAddressHttpClientBuilder appendClientFilter(Predicate predicate, + StreamingHttpClientFilterFactory factory) { + return (BaseSingleAddressHttpClientBuilder) super.appendClientFilter(predicate, factory); + } + @Override public abstract BaseSingleAddressHttpClientBuilder disableHostHeaderFallback(); diff --git a/servicetalk-http-api/src/main/java/io/servicetalk/http/api/MultiAddressHttpClientBuilder.java b/servicetalk-http-api/src/main/java/io/servicetalk/http/api/MultiAddressHttpClientBuilder.java index 369a7c7b6b..3fd351943e 100644 --- a/servicetalk-http-api/src/main/java/io/servicetalk/http/api/MultiAddressHttpClientBuilder.java +++ b/servicetalk-http-api/src/main/java/io/servicetalk/http/api/MultiAddressHttpClientBuilder.java @@ -60,6 +60,9 @@ public abstract class MultiAddressHttpClientBuilder @Override public abstract MultiAddressHttpClientBuilder enableWireLogging(String loggerName); + @Override + public abstract MultiAddressHttpClientBuilder protocols(HttpProtocolConfig... protocols); + @Override public abstract MultiAddressHttpClientBuilder disableHostHeaderFallback(); @@ -112,8 +115,7 @@ public abstract MultiAddressHttpClientBuilder unresolvedAddressToHost( @Override public MultiAddressHttpClientBuilder appendClientFilter(final Predicate predicate, final StreamingHttpClientFilterFactory factory) { - super.appendClientFilter(predicate, factory); - return this; + return (MultiAddressHttpClientBuilder) super.appendClientFilter(predicate, factory); } /** @@ -164,7 +166,6 @@ public MultiAddressHttpClientBuilder appendClientFilter(Predicate factory) { requireNonNull(predicate); requireNonNull(factory); - return appendClientFilter(toMultiAddressConditionalFilterFactory(predicate, factory)); }