File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -56,7 +56,9 @@ public Object invoke(Object[] argv) throws Throwable {
5656 retryer .continueOrPropagate (e );
5757 } catch (RetryableException th ) {
5858 Throwable cause = th .getCause ();
59- if (methodHandlerConfiguration .getPropagationPolicy () == UNWRAP && cause != null ) {
59+ if (methodHandlerConfiguration .getPropagationPolicy () == UNWRAP
60+ && cause != null
61+ && (cause instanceof RuntimeException || cause instanceof Error )) {
6062 throw cause ;
6163 } else {
6264 throw th ;
Original file line number Diff line number Diff line change 5050import feign .querymap .FieldQueryMapEncoder ;
5151import java .io .IOException ;
5252import java .lang .reflect .Type ;
53+ import java .net .ProtocolException ;
5354import java .net .URI ;
5455import java .time .Clock ;
5556import java .time .Instant ;
@@ -708,6 +709,22 @@ void throwsRetryableExceptionIfNoUnderlyingCause() throws Exception {
708709 assertThat (exception .getMessage ()).contains (message );
709710 }
710711
712+ @ Test
713+ void doesNotUnwrapCheckedCauseWhenPropagationPolicyIsUnwrap () {
714+ TestInterface api =
715+ Feign .builder ()
716+ .exceptionPropagationPolicy (UNWRAP )
717+ .retryer (new DefaultRetryer (1 , 1 , 1 ))
718+ .client (
719+ (_ , _ ) -> {
720+ throw new ProtocolException ("missing Location header for redirect" );
721+ })
722+ .target (TestInterface .class , "http://localhost:" + server .getPort ());
723+
724+ RetryableException exception = assertThrows (RetryableException .class , () -> api .post ());
725+ assertThat (exception .getCause ()).isInstanceOf (ProtocolException .class );
726+ }
727+
711728 @ Test
712729 void whenReturnTypeIsResponseNoErrorHandling () {
713730 Map <String , Collection <String >> headers = new LinkedHashMap <>();
You can’t perform that action at this time.
0 commit comments