From 9630554b045b7745b2d45647f868b4e48d57ebea Mon Sep 17 00:00:00 2001 From: Hesam Rahimi Date: Wed, 7 Jun 2017 13:59:48 -0400 Subject: [PATCH] Fix a bug in generic post operation: Do not read the entity if the responseClass is of type Response. Change-Id: I7dfe5f8ebcf90a8870433f16dfe334ae9a840402 --- .../onosproject/protocol/http/ctl/HttpSBControllerImpl.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/protocols/rest/api/src/main/java/org/onosproject/protocol/http/ctl/HttpSBControllerImpl.java b/protocols/rest/api/src/main/java/org/onosproject/protocol/http/ctl/HttpSBControllerImpl.java index 29fc70580b..4a893fcb79 100644 --- a/protocols/rest/api/src/main/java/org/onosproject/protocol/http/ctl/HttpSBControllerImpl.java +++ b/protocols/rest/api/src/main/java/org/onosproject/protocol/http/ctl/HttpSBControllerImpl.java @@ -145,7 +145,9 @@ public class HttpSBControllerImpl implements HttpSBController { Class 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;