Skip to content

Commit 7b646ab

Browse files
rfalkeadriancole
authored andcommitted
Also wrap the exception of Decoder.decode() in case of a 404. (OpenFeign#487)
1 parent 95f78cb commit 7b646ab

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

‎core/src/main/java/feign/SynchronousMethodHandler.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ Object executeAndDecode(RequestTemplate template) throws Throwable {
133133
return decode(response);
134134
}
135135
} else if (decode404 && response.status() == 404) {
136-
return decoder.decode(response, metadata.returnType());
136+
return decode(response);
137137
} else {
138138
throw errorDecoder.decode(metadata.configKey(), response);
139139
}

‎core/src/test/java/feign/FeignTest.java‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252

5353
import static feign.Util.UTF_8;
5454
import static feign.assertj.MockWebServerAssertions.assertThat;
55+
import static org.hamcrest.CoreMatchers.isA;
5556
import static org.junit.Assert.assertEquals;
5657
import static org.junit.Assert.assertTrue;
5758

@@ -546,9 +547,10 @@ public Object decode(Response response, Type type) throws IOException {
546547
}
547548

548549
@Test
549-
public void decoderCanThrowUnwrappedExceptionInDecode404Mode() throws Exception {
550+
public void decodingExceptionGetWrappedInDecode404Mode() throws Exception {
550551
server.enqueue(new MockResponse().setResponseCode(404));
551-
thrown.expect(NoSuchElementException.class);
552+
thrown.expect(DecodeException.class);
553+
thrown.expectCause(isA(NoSuchElementException.class));;
552554

553555
TestInterface api = new TestInterfaceBuilder()
554556
.decode404()

0 commit comments

Comments
 (0)