Skip to content

Commit e3daeb3

Browse files
wplong11velo
andauthored
Fix false negative test case for AsyncFeign Retry feature (#1795)
False negative test case is added in PR #1757 Co-authored-by: Marvin Froeder <velo@users.noreply.github.com>
1 parent 6a74bac commit e3daeb3

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

core/src/test/java/feign/AsyncFeignTest.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -564,39 +564,39 @@ public void throwsFeignExceptionWithoutBody() {
564564
}
565565

566566
@Test
567-
public void ensureRetryerClonesItself() throws Exception {
567+
public void ensureRetryerClonesItself() throws Throwable {
568568
server.enqueue(new MockResponse().setResponseCode(503).setBody("foo 1"));
569569
server.enqueue(new MockResponse().setResponseCode(200).setBody("foo 2"));
570570
server.enqueue(new MockResponse().setResponseCode(503).setBody("foo 3"));
571571
server.enqueue(new MockResponse().setResponseCode(200).setBody("foo 4"));
572572

573573
MockRetryer retryer = new MockRetryer();
574574

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

585-
api.post();
586-
api.post(); // if retryer instance was reused, this statement will throw an exception
585+
unwrap(api.post());
586+
unwrap(api.post()); // if retryer instance was reused, this statement will throw an exception
587587
assertEquals(4, server.getRequestCount());
588588
}
589589

590590
@Test
591-
public void throwsOriginalExceptionAfterFailedRetries() throws Exception {
591+
public void throwsOriginalExceptionAfterFailedRetries() throws Throwable {
592592
server.enqueue(new MockResponse().setResponseCode(503).setBody("foo 1"));
593593
server.enqueue(new MockResponse().setResponseCode(503).setBody("foo 2"));
594594

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

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

610-
api.post();
610+
unwrap(api.post());
611611
}
612612

613613
@Test
614-
public void throwsRetryableExceptionIfNoUnderlyingCause() throws Exception {
614+
public void throwsRetryableExceptionIfNoUnderlyingCause() throws Throwable {
615615
server.enqueue(new MockResponse().setResponseCode(503).setBody("foo 1"));
616616
server.enqueue(new MockResponse().setResponseCode(503).setBody("foo 2"));
617617

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

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

633-
api.post();
633+
unwrap(api.post());
634634
}
635635

636636
@SuppressWarnings("deprecation")

0 commit comments

Comments
 (0)