Skip to content

Commit

Permalink
Remove the unused code from the MethodInfo (#1785)
Browse files Browse the repository at this point in the history
The MethodInfo.configKey field is not more used since PR #1757 removing AsyncInvocation

Co-authored-by: Marvin Froeder <velo@users.noreply.github.com>
  • Loading branch information
wplong11 and velo authored Oct 11, 2022
1 parent b23cb41 commit d37634e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 18 deletions.
10 changes: 1 addition & 9 deletions core/src/main/java/feign/MethodInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,15 @@

@Experimental
public class MethodInfo {
private final String configKey;
private final Type underlyingReturnType;
private final boolean asyncReturnType;

protected MethodInfo(String configKey, Type underlyingReturnType, boolean asyncReturnType) {
this.configKey = configKey;
protected MethodInfo(Type underlyingReturnType, boolean asyncReturnType) {
this.underlyingReturnType = underlyingReturnType;
this.asyncReturnType = asyncReturnType;
}

MethodInfo(Class<?> targetType, Method method) {
this.configKey = Feign.configKey(targetType, method);

final Type type = Types.resolve(targetType, targetType, method.getGenericReturnType());

if (type instanceof ParameterizedType
Expand All @@ -45,10 +41,6 @@ protected MethodInfo(String configKey, Type underlyingReturnType, boolean asyncR
}
}

String configKey() {
return configKey;
}

Type underlyingReturnType() {
return underlyingReturnType;
}
Expand Down
4 changes: 0 additions & 4 deletions core/src/test/java/feign/MethodInfoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ public interface AsyncClient {
@Test
public void testCompletableFutureOfString() throws Exception {
MethodInfo mi = new MethodInfo(AsyncClient.class, AsyncClient.class.getMethod("log"));
assertEquals("AsyncClient#log()", mi.configKey());
assertTrue(mi.isAsyncReturnType());
assertEquals(String.class, mi.underlyingReturnType());
}
Expand All @@ -50,7 +49,6 @@ public interface AsyncClient extends GenericAsyncClient<CompletableFuture<String
@Test
public void testGenericCompletableFutureOfString() throws Exception {
MethodInfo mi = new MethodInfo(AsyncClient.class, AsyncClient.class.getMethod("log"));
assertEquals("AsyncClient#log()", mi.configKey());
assertTrue(mi.isAsyncReturnType());
assertEquals(String.class, mi.underlyingReturnType());
}
Expand All @@ -64,7 +62,6 @@ public interface SyncClient {
@Test
public void testString() throws Exception {
MethodInfo mi = new MethodInfo(SyncClient.class, SyncClient.class.getMethod("log"));
assertEquals("SyncClient#log()", mi.configKey());
assertFalse(mi.isAsyncReturnType());
assertEquals(String.class, mi.underlyingReturnType());
}
Expand Down Expand Up @@ -98,7 +95,6 @@ public Type getOwnerType() {
@Test
public void testListOfStrings() throws Exception {
MethodInfo mi = new MethodInfo(SyncClient.class, SyncClient.class.getMethod("log"));
assertEquals("SyncClient#log()", mi.configKey());
assertFalse(mi.isAsyncReturnType());
assertTrue(Types.equals(new ListOfStrings(), mi.underlyingReturnType()));
}
Expand Down
9 changes: 4 additions & 5 deletions kotlin/src/main/java/feign/kotlin/KotlinMethodInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,11 @@

class KotlinMethodInfo extends MethodInfo {

KotlinMethodInfo(String configKey, Type underlyingReturnType, boolean asyncReturnType) {
super(configKey, underlyingReturnType, asyncReturnType);
KotlinMethodInfo(Type underlyingReturnType, boolean asyncReturnType) {
super(underlyingReturnType, asyncReturnType);
}

static KotlinMethodInfo createInstance(Class<?> targetType, Method method) {
String configKey = Feign.configKey(targetType, method);

final Type type = Types.resolve(targetType, targetType, method.getGenericReturnType());

Type underlyingReturnType;
Expand All @@ -38,6 +36,7 @@ static KotlinMethodInfo createInstance(Class<?> targetType, Method method) {
asyncReturnType = true;
underlyingReturnType = MethodKt.getKotlinMethodReturnType(method);
if (underlyingReturnType == null) {
String configKey = Feign.configKey(targetType, method);
throw new IllegalArgumentException(
String.format(
"Method %s can't have continuation argument, only kotlin method is allowed",
Expand All @@ -52,6 +51,6 @@ static KotlinMethodInfo createInstance(Class<?> targetType, Method method) {
underlyingReturnType = type;
}

return new KotlinMethodInfo(configKey, underlyingReturnType, asyncReturnType);
return new KotlinMethodInfo(underlyingReturnType, asyncReturnType);
}
}

0 comments on commit d37634e

Please sign in to comment.