Skip to content

Commit

Permalink
append warn log only when MediaType present (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
alalag1 authored Jan 11, 2021
1 parent 20fecfa commit ce8fe48
Showing 1 changed file with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,20 +97,24 @@ protected byte[] resolve0(Object returnValue,
}

HttpResponseSerializer serializer = null;
for (MediaType mediaType : mediaTypes) {
for (HttpResponseSerializer ser : serializers) {
if (ser.supportsWrite(mediaType, returnValue.getClass())) {
serializer = ser;
break;
if (mediaTypes.isEmpty()) {
serializer = serializers.get(0);
} else {
for (MediaType mediaType : mediaTypes) {
for (HttpResponseSerializer ser : serializers) {
if (ser.supportsWrite(mediaType, returnValue.getClass())) {
serializer = ser;
break;
}
}
}
if (serializer == null) {
logger.warn("Failed to find serializer for media type '{}', try to use default serializer.",
mediaTypes);
serializer = serializers.get(0);
}
}

if (serializer == null) {
logger.warn("Failed to find serializer for media type '{}', try to use default serializer.",
mediaTypes);
serializer = serializers.get(0);
}
final Object returnValueToWrite = serializer.customResponse(request, response, returnValue);
return Serializers.serializeBySerializer(serializer, returnValueToWrite, response);
}
Expand Down

0 comments on commit ce8fe48

Please sign in to comment.