Fix a bug in generic post operation: Do not read the entity if
the responseClass is of type Response.
Change-Id: I7dfe5f8ebcf90a8870433f16dfe334ae9a840402
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 29fc705..4a893fcb 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 @@
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;