Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 0 additions & 2 deletions gson/src/main/java/feign/gson/GsonDecoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ public GsonDecoder(Gson gson) {

@Override
public Object decode(Response response, Type type) throws IOException {
if (response.status() == 404)
return Util.emptyValueOf(type);
if (response.body() == null)
return null;
Reader reader = response.body().asReader();
Expand Down
4 changes: 2 additions & 2 deletions gson/src/test/java/feign/gson/GsonCodecTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -228,13 +228,13 @@ public void customEncoder() {

/** Enabled via {@link feign.Feign.Builder#decode404()} */
@Test
public void notFoundDecodesToEmpty() throws Exception {
public void notFoundDecodesToNull() throws Exception {
Response response = Response.builder()
.status(404)
.reason("NOT FOUND")
.headers(Collections.emptyMap())
.request(Request.create(HttpMethod.GET, "/api", Collections.emptyMap(), null, Util.UTF_8))
.build();
assertThat((byte[]) new GsonDecoder().decode(response, byte[].class)).isEmpty();
assertThat((byte[]) new GsonDecoder().decode(response, byte[].class)).isNull();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ public JacksonJaxbJsonDecoder(ObjectMapper objectMapper) {

@Override
public Object decode(Response response, Type type) throws IOException, FeignException {
if (response.status() == 404)
return Util.emptyValueOf(type);
if (response.body() == null)
return null;
return jacksonJaxbJsonProvider.readFrom(Object.class, type, null, APPLICATION_JSON_TYPE, null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ public void decodeTest() throws Exception {
* Enabled via {@link feign.Feign.Builder#decode404()}
*/
@Test
public void notFoundDecodesToEmpty() throws Exception {
public void notFoundDecodesToNull() throws Exception {
Response response = Response.builder()
.status(404)
.reason("NOT FOUND")
.request(Request.create(HttpMethod.GET, "/api", Collections.emptyMap(), null, Util.UTF_8))
.headers(Collections.emptyMap())
.build();
assertThat((byte[]) new JacksonJaxbJsonDecoder().decode(response, byte[].class)).isEmpty();
assertThat((byte[]) new JacksonJaxbJsonDecoder().decode(response, byte[].class)).isNull();
}

@XmlRootElement
Expand Down
2 changes: 0 additions & 2 deletions jackson/src/main/java/feign/jackson/JacksonDecoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ public JacksonDecoder(ObjectMapper mapper) {

@Override
public Object decode(Response response, Type type) throws IOException {
if (response.status() == 404)
return Util.emptyValueOf(type);
if (response.body() == null)
return null;
Reader reader = response.body().asReader();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ public final class JacksonIteratorDecoder implements Decoder {

@Override
public Object decode(Response response, Type type) throws IOException {
if (response.status() == 404)
return Util.emptyValueOf(type);
if (response.body() == null)
return null;
Reader reader = response.body().asReader();
Expand Down
8 changes: 4 additions & 4 deletions jackson/src/test/java/feign/jackson/JacksonCodecTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -281,25 +281,25 @@ public void serialize(Zone value, JsonGenerator jgen, SerializerProvider provide

/** Enabled via {@link feign.Feign.Builder#decode404()} */
@Test
public void notFoundDecodesToEmpty() throws Exception {
public void notFoundDecodesToNull() throws Exception {
Response response = Response.builder()
.status(404)
.reason("NOT FOUND")
.request(Request.create(HttpMethod.GET, "/api", Collections.emptyMap(), null, Util.UTF_8))
.headers(Collections.emptyMap())
.build();
assertThat((byte[]) new JacksonDecoder().decode(response, byte[].class)).isEmpty();
assertThat((byte[]) new JacksonDecoder().decode(response, byte[].class)).isNull();
}

/** Enabled via {@link feign.Feign.Builder#decode404()} */
@Test
public void notFoundDecodesToEmptyIterator() throws Exception {
public void notFoundDecodesToNullIterator() throws Exception {
Response response = Response.builder()
.status(404)
.reason("NOT FOUND")
.request(Request.create(HttpMethod.GET, "/api", Collections.emptyMap(), null, Util.UTF_8))
.headers(Collections.emptyMap())
.build();
assertThat((byte[]) JacksonIteratorDecoder.create().decode(response, byte[].class)).isEmpty();
assertThat((byte[]) JacksonIteratorDecoder.create().decode(response, byte[].class)).isNull();
}
}
2 changes: 1 addition & 1 deletion jaxb/src/main/java/feign/jaxb/JAXBDecoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ private JAXBDecoder(Builder builder) {

@Override
public Object decode(Response response, Type type) throws IOException {
if (response.status() == 404 || response.status() == 204)
if (response.status() == 204)
return Util.emptyValueOf(type);
if (response.body() == null)
return null;
Expand Down
4 changes: 2 additions & 2 deletions jaxb/src/test/java/feign/jaxb/JAXBCodecTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -244,15 +244,15 @@ public void decodeAnnotatedParameterizedTypes() throws Exception {
* Enabled via {@link feign.Feign.Builder#decode404()}
*/
@Test
public void notFoundDecodesToEmpty() throws Exception {
public void notFoundDecodesToNull() throws Exception {
Response response = Response.builder()
.status(404)
.reason("NOT FOUND")
.request(Request.create(HttpMethod.GET, "/api", Collections.emptyMap(), null, Util.UTF_8))
.headers(Collections.<String, Collection<String>>emptyMap())
.build();
assertThat((byte[]) new JAXBDecoder(new JAXBContextFactory.Builder().build())
.decode(response, byte[].class)).isEmpty();
.decode(response, byte[].class)).isNull();
}

@XmlRootElement
Expand Down
2 changes: 0 additions & 2 deletions sax/src/main/java/feign/sax/SAXDecoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ public static Builder builder() {

@Override
public Object decode(Response response, Type type) throws IOException, DecodeException {
if (response.status() == 404)
return Util.emptyValueOf(type);
if (response.body() == null)
return null;
ContentHandlerWithResult.Factory<?> handlerFactory = handlerFactories.get(type);
Expand Down
4 changes: 2 additions & 2 deletions sax/src/test/java/feign/sax/SAXDecoderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,14 @@ public void nullBodyDecodesToNull() throws Exception {

/** Enabled via {@link feign.Feign.Builder#decode404()} */
@Test
public void notFoundDecodesToEmpty() throws Exception {
public void notFoundDecodesToNull() throws Exception {
Response response = Response.builder()
.status(404)
.reason("NOT FOUND")
.request(Request.create(HttpMethod.GET, "/api", Collections.emptyMap(), null, Util.UTF_8))
.headers(Collections.<String, Collection<String>>emptyMap())
.build();
assertThat((byte[]) decoder.decode(response, byte[].class)).isEmpty();
assertThat((byte[]) decoder.decode(response, byte[].class)).isNull();
}

static enum NetworkStatus {
Expand Down
4 changes: 2 additions & 2 deletions soap/src/test/java/feign/soap/SOAPCodecTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -338,15 +338,15 @@ public void decodeAnnotatedParameterizedTypes() throws Exception {
* Enabled via {@link feign.Feign.Builder#decode404()}
*/
@Test
public void notFoundDecodesToEmpty() throws Exception {
public void notFoundDecodesToNull() throws Exception {
Response response = Response.builder()
.status(404)
.reason("NOT FOUND")
.request(Request.create(HttpMethod.GET, "/api", Collections.emptyMap(), null, Util.UTF_8))
.headers(Collections.<String, Collection<String>>emptyMap())
.build();
assertThat((byte[]) new JAXBDecoder(new JAXBContextFactory.Builder().build())
.decode(response, byte[].class)).isEmpty();
.decode(response, byte[].class)).isNull();
}


Expand Down