Skip to content

Commit

Permalink
fix(Issue jpos#208): Jpos hangs on htp response 204 no content
Browse files Browse the repository at this point in the history
Jpos hangs when a server response is 204 no content. in the case where
the responseBodyOnError is set true and the response status is 204 jpos
hangs becuase there is no response body to process. This causes the
EntityUtils to attempt to process the response, calling the
result.getEntity() which does nothing. This change allows for the
situation where 204 is the response staus, and the responseBodyOnError
to be true but not call the EntityUtils when there is no response body
to process, by adding the status to the context using the mapping value
of HTTP_RESPONSE_STATUS
  • Loading branch information
jamesloveday committed Mar 23, 2021
1 parent f7f4dce commit ae06f66
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,11 @@ public void completed(HttpResponse result) {
boolean includeResponse= (sc == HttpStatus.SC_CREATED) || (sc == HttpStatus.SC_OK) || responseOnError;
if (includeResponse) {
try {
ctx.put (responseName, EntityUtils.toString(result.getEntity()));
if (result.getEntity() != null) {
ctx.put(responseName, EntityUtils.toString(result.getEntity()));
} else {
ctx.put("HTTP_RESPONSE_STATUS", sc);
}
} catch (IOException e) {
ctx.log (e);
}
Expand Down Expand Up @@ -406,4 +410,4 @@ private CloseableHttpAsyncClient destroyClient (CloseableHttpAsyncClient client)
}
return null;
}
}
}

0 comments on commit ae06f66

Please sign in to comment.