Fix a bug in generic post operation: Do not read the entity if

the responseClass is of type Response.

Change-Id: I7dfe5f8ebcf90a8870433f16dfe334ae9a840402
This commit is contained in:
Hesam Rahimi 2017-06-07 13:59:48 -04:00 committed by Thomas Vachuska
parent f9f1dbe116
commit 9630554b04

View File

@ -145,7 +145,9 @@ public class HttpSBControllerImpl implements HttpSBController {
Class<T> responseClass) {
Response response = getResponse(device, request, payload, mediaType);
if (response != null && response.hasEntity()) {
return response.readEntity(responseClass);
// Do not read the entity if the responseClass is of type Response. This would allow the
// caller to receive the Response directly and try to read its appropriate entity locally.
return responseClass == Response.class ? (T) response : response.readEntity(responseClass);
}
log.error("Response from device {} for request {} contains no entity", device, request);
return null;