Skip to content

Commit

Permalink
Refactor constructor of ReflectiveFeign (#1857)
Browse files Browse the repository at this point in the history
  • Loading branch information
wplong11 authored Nov 22, 2022
1 parent e572e10 commit 0b4157a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
6 changes: 2 additions & 4 deletions core/src/main/java/feign/AsyncFeign.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

import feign.InvocationHandlerFactory.MethodHandler;
import feign.Logger.Level;
import feign.ReflectiveFeign.ParseHandlersByName;
import feign.Request.Options;
import feign.Target.HardCodedTarget;
import feign.codec.Decoder;
Expand Down Expand Up @@ -218,10 +217,9 @@ public AsyncFeign<C> build() {
options,
decoder,
errorDecoder);
final ParseHandlersByName<C> handlersByName =
new ParseHandlersByName<>(contract, methodHandlerFactory);
final ReflectiveFeign<C> feign =
new ReflectiveFeign<>(handlersByName, invocationHandlerFactory, defaultContextSupplier);
new ReflectiveFeign<>(
contract, methodHandlerFactory, invocationHandlerFactory, defaultContextSupplier);
return new AsyncFeign<>(feign);
}
}
Expand Down
8 changes: 3 additions & 5 deletions core/src/main/java/feign/Feign.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
package feign;

import feign.InvocationHandlerFactory.MethodHandler;
import feign.ReflectiveFeign.ParseHandlersByName;
import feign.Request.Options;
import feign.Target.HardCodedTarget;
import feign.codec.Decoder;
Expand Down Expand Up @@ -208,7 +207,7 @@ public Feign build() {
dismiss404,
closeAfterDecode,
responseInterceptor);
MethodHandler.Factory<Object> synchronousMethodHandlerFactory =
MethodHandler.Factory<Object> methodHandlerFactory =
new SynchronousMethodHandler.Factory(
client,
retryer,
Expand All @@ -219,9 +218,8 @@ public Feign build() {
propagationPolicy,
new RequestTemplateFactoryResolver(encoder, queryMapEncoder),
options);
ParseHandlersByName<Object> handlersByName =
new ParseHandlersByName<>(contract, synchronousMethodHandlerFactory);
return new ReflectiveFeign<>(handlersByName, invocationHandlerFactory, () -> null);
return new ReflectiveFeign<>(
contract, methodHandlerFactory, invocationHandlerFactory, () -> null);
}
}

Expand Down
11 changes: 6 additions & 5 deletions core/src/main/java/feign/ReflectiveFeign.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ public class ReflectiveFeign<C> extends Feign {
private final AsyncContextSupplier<C> defaultContextSupplier;

ReflectiveFeign(
ParseHandlersByName<C> targetToHandlersByName,
InvocationHandlerFactory factory,
Contract contract,
MethodHandler.Factory<C> methodHandlerFactory,
InvocationHandlerFactory invocationHandlerFactory,
AsyncContextSupplier<C> defaultContextSupplier) {
this.targetToHandlersByName = targetToHandlersByName;
this.factory = factory;
this.targetToHandlersByName = new ParseHandlersByName<C>(contract, methodHandlerFactory);
this.factory = invocationHandlerFactory;
this.defaultContextSupplier = defaultContextSupplier;
}

Expand Down Expand Up @@ -118,7 +119,7 @@ public String toString() {
}
}

static final class ParseHandlersByName<C> {
private static final class ParseHandlersByName<C> {

private final Contract contract;
private final MethodHandler.Factory<C> factory;
Expand Down

0 comments on commit 0b4157a

Please sign in to comment.