Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix false negative test case for AsyncFeign Retry feature #1795

Merged
merged 2 commits into from
Oct 20, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions core/src/test/java/feign/AsyncFeignTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -564,39 +564,39 @@ public void throwsFeignExceptionWithoutBody() {
}

@Test
public void ensureRetryerClonesItself() throws Exception {
public void ensureRetryerClonesItself() throws Throwable {
server.enqueue(new MockResponse().setResponseCode(503).setBody("foo 1"));
server.enqueue(new MockResponse().setResponseCode(200).setBody("foo 2"));
server.enqueue(new MockResponse().setResponseCode(503).setBody("foo 3"));
server.enqueue(new MockResponse().setResponseCode(200).setBody("foo 4"));

MockRetryer retryer = new MockRetryer();

FeignTest.TestInterface api = Feign.builder()
TestInterfaceAsync api = AsyncFeign.builder()
.retryer(retryer)
.errorDecoder(new ErrorDecoder() {
@Override
public Exception decode(String methodKey, Response response) {
return new RetryableException(response.status(), "play it again sam!", HttpMethod.POST,
null, response.request());
}
}).target(FeignTest.TestInterface.class, "http://localhost:" + server.getPort());
}).target(TestInterfaceAsync.class, "http://localhost:" + server.getPort());

api.post();
api.post(); // if retryer instance was reused, this statement will throw an exception
unwrap(api.post());
unwrap(api.post()); // if retryer instance was reused, this statement will throw an exception
assertEquals(4, server.getRequestCount());
}

@Test
public void throwsOriginalExceptionAfterFailedRetries() throws Exception {
public void throwsOriginalExceptionAfterFailedRetries() throws Throwable {
server.enqueue(new MockResponse().setResponseCode(503).setBody("foo 1"));
server.enqueue(new MockResponse().setResponseCode(503).setBody("foo 2"));

final String message = "the innerest";
thrown.expect(TestInterfaceException.class);
thrown.expectMessage(message);

TestInterfaceAsync api = Feign.builder()
TestInterfaceAsync api = AsyncFeign.builder()
.exceptionPropagationPolicy(UNWRAP)
.retryer(new Retryer.Default(1, 1, 2))
.errorDecoder(new ErrorDecoder() {
Expand All @@ -607,19 +607,19 @@ public Exception decode(String methodKey, Response response) {
}
}).target(TestInterfaceAsync.class, "http://localhost:" + server.getPort());

api.post();
unwrap(api.post());
}

@Test
public void throwsRetryableExceptionIfNoUnderlyingCause() throws Exception {
public void throwsRetryableExceptionIfNoUnderlyingCause() throws Throwable {
server.enqueue(new MockResponse().setResponseCode(503).setBody("foo 1"));
server.enqueue(new MockResponse().setResponseCode(503).setBody("foo 2"));

String message = "play it again sam!";
thrown.expect(RetryableException.class);
thrown.expectMessage(message);

TestInterfaceAsync api = Feign.builder()
TestInterfaceAsync api = AsyncFeign.builder()
.exceptionPropagationPolicy(UNWRAP)
.retryer(new Retryer.Default(1, 1, 2))
.errorDecoder(new ErrorDecoder() {
Expand All @@ -630,7 +630,7 @@ public Exception decode(String methodKey, Response response) {
}
}).target(TestInterfaceAsync.class, "http://localhost:" + server.getPort());

api.post();
unwrap(api.post());
}

@SuppressWarnings("deprecation")
Expand Down