Skip to content
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
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 @@ -66,7 +66,7 @@ private JAXBDecoder(Builder builder) {

@Override
public Object decode(Response response, Type type) throws IOException {
if (response.status() == 404)
if (response.status() == 404 || response.status() == 204)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds fair.

Could you just add a test for 204 as well?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we do this globally or just in this decoder? @velo?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or better yet, we should inspect the body before sending it to the Decoder here:

Object decode(Response response) throws Throwable {
try {
return decoder.decode(response, metadata.returnType());
} catch (FeignException e) {
throw e;
} catch (RuntimeException e) {
throw new DecodeException(e.getMessage(), e);
}
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer a global way to handle it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we do this globally or just in this decoder?

@kdavisk6 we could, but that would break current API for all decoders...

If you think of a OptionalDecoder the result for a 204 or 404 is Optional.empty()

For a JAXB decoder null
For a List decoder may be Collections.emptyList() (which I currently use for a binary format decoder.

So, although I would like to see this in a single location, I don't think we can.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough. Let's go with this for now and keep an eye out for other issues.

return Util.emptyValueOf(type);
if (response.body() == null)
return null;
Expand Down