Browse Source

fix:issue 1420 (#1620)

pull/1628/head
mroccyen 3 years ago committed by GitHub
parent
commit
d27d385e1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      core/src/main/java/feign/Contract.java
  2. 21
      core/src/test/java/feign/OptionsTest.java

3
core/src/main/java/feign/Contract.java

@ -132,7 +132,8 @@ public interface Contract { @@ -132,7 +132,8 @@ public interface Contract {
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());

21
core/src/test/java/feign/OptionsTest.java

@ -29,10 +29,19 @@ import static org.assertj.core.api.Assertions.assertThat; @@ -29,10 +29,19 @@ import static org.assertj.core.api.Assertions.assertThat;
@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();
}
@ -66,4 +75,16 @@ public class OptionsTest { @@ -66,4 +75,16 @@ public class OptionsTest {
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");
}
}

Loading…
Cancel
Save