Skip to content

Commit

Permalink
fix:issue 1420 (#1620)
Browse files Browse the repository at this point in the history
  • Loading branch information
mroccyen authored May 20, 2022
1 parent 75721d1 commit d27d385
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
3 changes: 2 additions & 1 deletion core/src/main/java/feign/Contract.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ protected MethodMetadata parseAndValidateMetadata(Class<?> targetType, Method me

if (parameterTypes[i] == URI.class) {
data.urlIndex(i);
} else if (!isHttpAnnotation && parameterTypes[i] != Request.Options.class) {
} else if (!isHttpAnnotation
&& !Request.Options.class.isAssignableFrom(parameterTypes[i])) {
if (data.isAlreadyProcessed(i)) {
checkState(data.formParams().isEmpty() || data.bodyIndex() == null,
"Body parameters cannot be used with form parameters.%s", data.warnings());
Expand Down
21 changes: 21 additions & 0 deletions core/src/test/java/feign/OptionsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,19 @@
@SuppressWarnings("deprecation")
public class OptionsTest {

static class ChildOptions extends Request.Options {
public ChildOptions(int connectTimeoutMillis, int readTimeoutMillis) {
super(connectTimeoutMillis, readTimeoutMillis);
}
}

interface OptionsInterface {
@RequestLine("GET /")
String get(Request.Options options);

@RequestLine("POST /")
String getChildOptions(ChildOptions options);

@RequestLine("GET /")
String get();
}
Expand Down Expand Up @@ -66,4 +75,16 @@ public void normalResponseTest() {

assertThat(api.get(new Request.Options(1000, 4 * 1000))).isEqualTo("foo");
}

@Test
public void normalResponseForChildOptionsTest() {
final MockWebServer server = new MockWebServer();
server.enqueue(new MockResponse().setBody("foo").setBodyDelay(3, TimeUnit.SECONDS));

final OptionsInterface api = Feign.builder()
.options(new ChildOptions(1000, 1000))
.target(OptionsInterface.class, server.url("/").toString());

assertThat(api.getChildOptions(new ChildOptions(1000, 4 * 1000))).isEqualTo("foo");
}
}

0 comments on commit d27d385

Please sign in to comment.