diff --git a/core/src/main/java/feign/AsyncFeign.java b/core/src/main/java/feign/AsyncFeign.java index cc5f02762..17261d45d 100644 --- a/core/src/main/java/feign/AsyncFeign.java +++ b/core/src/main/java/feign/AsyncFeign.java @@ -14,8 +14,11 @@ package feign; import feign.Logger.Level; +import feign.Request.Options; import feign.Target.HardCodedTarget; import feign.codec.Decoder; +import feign.codec.Encoder; +import feign.codec.ErrorDecoder; import java.io.IOException; import java.util.Optional; import java.util.concurrent.CompletableFuture; @@ -70,17 +73,46 @@ public AsyncBuilder defaultContextSupplier(Supplier supplier) { return this; } - public AsyncBuilder defaultContextSupplier(AsyncContextSupplier supplier) { - this.defaultContextSupplier = supplier; + public AsyncBuilder client(AsyncClient client) { + this.client = client; return this; } + @Override + public AsyncBuilder mapAndDecode(ResponseMapper mapper, Decoder decoder) { + return super.mapAndDecode(mapper, decoder); + } - public AsyncBuilder client(AsyncClient client) { - this.client = client; - return this; + @Override + public AsyncBuilder decoder(Decoder decoder) { + return super.decoder(decoder); + } + + @Override + @Deprecated + public AsyncBuilder decode404() { + return super.decode404(); } + @Override + public AsyncBuilder dismiss404() { + return super.dismiss404(); + } + + @Override + public AsyncBuilder errorDecoder(ErrorDecoder errorDecoder) { + return super.errorDecoder(errorDecoder); + } + + @Override + public AsyncBuilder doNotCloseAfterDecode() { + return super.doNotCloseAfterDecode(); + } + + public AsyncBuilder defaultContextSupplier(AsyncContextSupplier supplier) { + this.defaultContextSupplier = supplier; + return this; + } public T target(Class apiType, String url) { return target(new HardCodedTarget<>(apiType, url)); @@ -98,6 +130,51 @@ public T target(Target target, C context) { return build().newInstance(target, context); } + @Override + public AsyncBuilder logLevel(Level logLevel) { + return super.logLevel(logLevel); + } + + @Override + public AsyncBuilder contract(Contract contract) { + return super.contract(contract); + } + + @Override + public AsyncBuilder logger(Logger logger) { + return super.logger(logger); + } + + @Override + public AsyncBuilder encoder(Encoder encoder) { + return super.encoder(encoder); + } + + @Override + public AsyncBuilder queryMapEncoder(QueryMapEncoder queryMapEncoder) { + return super.queryMapEncoder(queryMapEncoder); + } + + @Override + public AsyncBuilder options(Options options) { + return super.options(options); + } + + @Override + public AsyncBuilder requestInterceptor(RequestInterceptor requestInterceptor) { + return super.requestInterceptor(requestInterceptor); + } + + @Override + public AsyncBuilder requestInterceptors(Iterable requestInterceptors) { + return super.requestInterceptors(requestInterceptors); + } + + @Override + public AsyncBuilder invocationHandlerFactory(InvocationHandlerFactory invocationHandlerFactory) { + return super.invocationHandlerFactory(invocationHandlerFactory); + } + public AsyncFeign build() { super.enrich(); ThreadLocal> activeContextHolder = new ThreadLocal<>(); @@ -216,8 +293,6 @@ protected AsyncFeign(Feign feign, AsyncContextSupplier defaultContextSupplier this.defaultContextSupplier = defaultContextSupplier; } - - @Override public T newInstance(Target target) { return newInstance(target, defaultContextSupplier.newContext()); diff --git a/core/src/main/java/feign/Feign.java b/core/src/main/java/feign/Feign.java index fe543fbe0..6134439ae 100644 --- a/core/src/main/java/feign/Feign.java +++ b/core/src/main/java/feign/Feign.java @@ -14,8 +14,11 @@ package feign; import feign.ReflectiveFeign.ParseHandlersByName; +import feign.Request.Options; import feign.Target.HardCodedTarget; import feign.codec.Decoder; +import feign.codec.Encoder; +import feign.codec.ErrorDecoder; import java.io.IOException; import java.lang.reflect.Method; import java.lang.reflect.Type; @@ -94,12 +97,98 @@ public static class Builder extends BaseBuilder { private Client client = new Client.Default(null, null); private boolean forceDecoding = false; + @Override + public Builder logLevel(Logger.Level logLevel) { + return super.logLevel(logLevel); + } + + @Override + public Builder contract(Contract contract) { + return super.contract(contract); + } + public Builder client(Client client) { this.client = client; return this; } + @Override + public Builder retryer(Retryer retryer) { + return super.retryer(retryer); + } + + @Override + public Builder logger(Logger logger) { + return super.logger(logger); + } + + @Override + public Builder encoder(Encoder encoder) { + return super.encoder(encoder); + } + + @Override + public Builder decoder(Decoder decoder) { + return super.decoder(decoder); + } + + @Override + public Builder queryMapEncoder(QueryMapEncoder queryMapEncoder) { + return super.queryMapEncoder(queryMapEncoder); + } + + @Override + public Builder mapAndDecode(ResponseMapper mapper, Decoder decoder) { + return super.mapAndDecode(mapper, decoder); + } + + @Deprecated + @Override + public Builder decode404() { + return super.decode404(); + } + + @Override + public Builder errorDecoder(ErrorDecoder errorDecoder) { + return super.errorDecoder(errorDecoder); + } + + @Override + public Builder options(Options options) { + return super.options(options); + } + + @Override + public Builder requestInterceptor(RequestInterceptor requestInterceptor) { + return super.requestInterceptor(requestInterceptor); + } + + @Override + public Builder requestInterceptors(Iterable requestInterceptors) { + return super.requestInterceptors(requestInterceptors); + } + + @Override + public Builder invocationHandlerFactory(InvocationHandlerFactory invocationHandlerFactory) { + return super.invocationHandlerFactory(invocationHandlerFactory); + } + + @Override + public Builder doNotCloseAfterDecode() { + return super.doNotCloseAfterDecode(); + } + + @Override + public Builder exceptionPropagationPolicy(ExceptionPropagationPolicy propagationPolicy) { + return super.exceptionPropagationPolicy(propagationPolicy); + } + + @Override + public Builder addCapability(Capability capability) { + return super.addCapability(capability); + } + /** * Internal - used to indicate that the decoder should be immediately called */ diff --git a/core/src/test/java/feign/BaseBuilderTest.java b/core/src/test/java/feign/BaseBuilderTest.java index 158fe30fb..1fc3fdf4f 100644 --- a/core/src/test/java/feign/BaseBuilderTest.java +++ b/core/src/test/java/feign/BaseBuilderTest.java @@ -17,54 +17,12 @@ import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.RETURNS_MOCKS; import java.lang.reflect.Field; -import java.util.Arrays; import java.util.List; -import java.util.Objects; -import java.util.stream.Collectors; import org.junit.Test; import org.mockito.Mockito; public class BaseBuilderTest { - @Test - public void avoidDuplicationsBetweenBuilders() { - List builderA = getExclusiveMethods(Feign.Builder.class); - List builderB = getExclusiveMethods(AsyncFeign.AsyncBuilder.class); - - assertThat(builderA).noneMatch(m -> builderB.contains(m)); - assertThat(builderB).noneMatch(m -> builderA.contains(m)); - - } - - @Test - public void avoidDuplicationsBetweenAsyncBuilderAndBaseBuilder() { - List builderA = getExclusiveMethods(BaseBuilder.class); - List builderB = getExclusiveMethods(AsyncFeign.AsyncBuilder.class); - - assertThat(builderA).noneMatch(m -> builderB.contains(m)); - assertThat(builderB).noneMatch(m -> builderA.contains(m)); - - } - - @Test - public void avoidDuplicationsBetweenBuilderAndBaseBuilder() { - List builderA = getExclusiveMethods(Feign.Builder.class); - List builderB = getExclusiveMethods(BaseBuilder.class); - - assertThat(builderA).noneMatch(m -> builderB.contains(m)); - assertThat(builderB).noneMatch(m -> builderA.contains(m)); - - } - - private List getExclusiveMethods(Class clazz) { - return Arrays.stream(clazz.getDeclaredMethods()) - .filter(m -> !Objects.equals(m.getName(), "target")) - .filter(m -> !Objects.equals(m.getName(), "build")) - .filter(m -> !m.isSynthetic()) - .map(m -> m.getName() + "#" + Arrays.toString(m.getParameterTypes())) - .collect(Collectors.toList()); - } - @Test public void checkEnrichTouchesAllAsyncBuilderFields() throws IllegalArgumentException, IllegalAccessException {