Skip to content

Commit

Permalink
Merge pull request #3132 from jamezp/RESTEASY-3089-3.15
Browse files Browse the repository at this point in the history
[RESTEASY-3089] ContainerResponseFilter will not allow null entities …
  • Loading branch information
jamezp committed Jul 6, 2022
2 parents 0c357d5 + a6d346a commit 4914a82
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Expand Up @@ -127,6 +127,9 @@ public Type getEntityType()
public void setEntity(Object entity)
{
//if (entity != null) logger.info("*** setEntity(Object) " + entity.toString());
if (entity != null && jaxrsResponse.getEntity() == null && jaxrsResponse.getStatusInfo().equals(Response.Status.NO_CONTENT)){
LogMessages.LOGGER.statusNotSet(Response.Status.NO_CONTENT.getStatusCode(), Response.Status.NO_CONTENT.getReasonPhrase());
}
jaxrsResponse.setEntity(entity);
// todo TCK does weird things in its testing of get length
// it resets the entity in a response filter which results
Expand All @@ -139,6 +142,9 @@ public void setEntity(Object entity)
public void setEntity(Object entity, Annotation[] annotations, MediaType mediaType)
{
//if (entity != null) logger.info("*** setEntity(Object, Annotation[], MediaType) " + entity.toString() + ", " + mediaType);
if (entity != null && jaxrsResponse.getEntity() == null && jaxrsResponse.getStatusInfo().equals(Response.Status.NO_CONTENT)){
LogMessages.LOGGER.statusNotSet(Response.Status.NO_CONTENT.getStatusCode(), Response.Status.NO_CONTENT.getReasonPhrase());
}
jaxrsResponse.setEntity(entity);
jaxrsResponse.setAnnotations(annotations);
jaxrsResponse.getHeaders().putSingle(HttpHeaders.CONTENT_TYPE, mediaType);
Expand Down
Expand Up @@ -178,6 +178,10 @@ public interface LogMessages extends BasicLogger
@Message(id = BASE + 196, value = "Component of type %s can't be dynamically bound to a resource method as a %s provider.")
void providerCantBeDynamicallyBoundToMethod(Class<?> componentClass, Class<?> providerType);

@LogMessage(level = Level.WARN)
@Message(id = BASE + 197, value = "The previous response status was {0} {1}. The status should be changed before the entity is set.", format = Format.MESSAGE_FORMAT)
void statusNotSet(int statusCode, String reasonPhrase);

///////////////////////////////////////////////////////////////////////////////////////////////////////////
// INFO //
///////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down

0 comments on commit 4914a82

Please sign in to comment.