From: Senthil Kumar G S Date: Wed, 5 Oct 2016 16:01:10 +0000 (+0530) Subject: Fix for IOT-1394. X-Git-Tag: 1.2.0+RC4~10 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=381c3eaa5825b5a5ea9a6e89af9baa2a63d76e12;p=platform%2Fupstream%2Fiotivity.git Fix for IOT-1394. In callbacks for GET, PUT, POST, and OBSERVE requests in InProcClientWrapper.cpp (CPP layer of RI), the representation was parsed only for success cases. But when we are dealing with cloud responses, they include a payload with error message and code even for error cases. To catch those responses, we should ignore the status(OCStackResult) of client response and let the error representation reach till application. Change-Id: I103957bb79e948693807fc05e8bed461e6b2d8dd Signed-off-by: Senthil Kumar G S Reviewed-on: https://gerrit.iotivity.org/gerrit/12831 Tested-by: jenkins-iotivity Reviewed-by: Uze Choi Reviewed-by: Abhishek Pandey Reviewed-by: Ziran Sun (cherry picked from commit 664340cc8b5c22d3441f11c34df2b5f3d1b8eff3) Reviewed-on: https://gerrit.iotivity.org/gerrit/13211 Reviewed-by: Harish Marappa Reviewed-by: Ashok Babu Channa --- diff --git a/resource/src/InProcClientWrapper.cpp b/resource/src/InProcClientWrapper.cpp index e5918a6..6283c72 100644 --- a/resource/src/InProcClientWrapper.cpp +++ b/resource/src/InProcClientWrapper.cpp @@ -657,17 +657,15 @@ namespace OC OCRepresentation rep; HeaderOptions serverHeaderOptions; OCStackResult result = clientResponse->result; - if (result == OC_STACK_OK) + + parseServerHeaderOptions(clientResponse, serverHeaderOptions); + try { - parseServerHeaderOptions(clientResponse, serverHeaderOptions); - try - { - rep = parseGetSetCallback(clientResponse); - } - catch(OC::OCException& e) - { - result = e.code(); - } + rep = parseGetSetCallback(clientResponse); + } + catch(OC::OCException& e) + { + result = e.code(); } std::thread exec(context->callback, serverHeaderOptions, rep, result); @@ -733,20 +731,15 @@ namespace OC HeaderOptions serverHeaderOptions; OCStackResult result = clientResponse->result; - if (OC_STACK_OK == result || - OC_STACK_RESOURCE_CREATED == result || - OC_STACK_RESOURCE_DELETED == result || - OC_STACK_RESOURCE_CHANGED == result) + + parseServerHeaderOptions(clientResponse, serverHeaderOptions); + try { - parseServerHeaderOptions(clientResponse, serverHeaderOptions); - try - { - attrs = parseGetSetCallback(clientResponse); - } - catch(OC::OCException& e) - { - result = e.code(); - } + attrs = parseGetSetCallback(clientResponse); + } + catch(OC::OCException& e) + { + result = e.code(); } std::thread exec(context->callback, serverHeaderOptions, attrs, result); @@ -947,10 +940,8 @@ namespace OC static_cast(ctx); HeaderOptions serverHeaderOptions; - if (clientResponse->result == OC_STACK_OK) - { - parseServerHeaderOptions(clientResponse, serverHeaderOptions); - } + parseServerHeaderOptions(clientResponse, serverHeaderOptions); + std::thread exec(context->callback, serverHeaderOptions, clientResponse->result); exec.detach(); return OC_STACK_DELETE_TRANSACTION; @@ -1013,18 +1004,17 @@ namespace OC HeaderOptions serverHeaderOptions; uint32_t sequenceNumber = clientResponse->sequenceNumber; OCStackResult result = clientResponse->result; - if (clientResponse->result == OC_STACK_OK) + + parseServerHeaderOptions(clientResponse, serverHeaderOptions); + try { - parseServerHeaderOptions(clientResponse, serverHeaderOptions); - try - { - attrs = parseGetSetCallback(clientResponse); - } - catch(OC::OCException& e) - { - result = e.code(); - } + attrs = parseGetSetCallback(clientResponse); } + catch(OC::OCException& e) + { + result = e.code(); + } + std::thread exec(context->callback, serverHeaderOptions, attrs, result, sequenceNumber); exec.detach();