Add exception handling logic in things configuration
authorJihun Ha <jihun.ha@samsung.com>
Wed, 14 Oct 2015 01:59:45 +0000 (10:59 +0900)
committerMadan Lanka <lanka.madan@samsung.com>
Wed, 14 Oct 2015 06:11:15 +0000 (06:11 +0000)
When calling constructResourceObject, it probably throws an exception.
To avoid a sudden crash for it, we add exception handling to it.

Additionaly, in oicgroup file, there is a condition statement which
may lead wrong way from what we expect. Thus we remove it.

Change-Id: Ibc12cd261ca875738446ad3b10b199ae15497654
Signed-off-by: Jihun Ha <jihun.ha@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/3865
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Madan Lanka <lanka.madan@samsung.com>
resource/csdk/stack/src/oicgroup.c
service/things-manager/sdk/src/ThingsConfiguration.cpp

index 864cced..20d8735 100755 (executable)
@@ -713,11 +713,6 @@ OCStackResult BuildActionSetFromString(OCActionSet **set, char* actiondesc)
             {
                 OC_LOG(INFO, TAG, "Build OCAction Instance.");
 
-                if(action)
-                {
-                    OICFree(action->resourceUri);
-                    OICFree(action);
-                }
                 action = (OCAction*) OICMalloc(sizeof(OCAction));
                 VARIFY_POINTER_NULL(action, result, exit)
                 memset(action, 0, sizeof(OCAction));
index e1aef9b..1d93883 100755 (executable)
@@ -327,10 +327,16 @@ namespace OIC
 
             std::string host = getHostFromURI(oit->getUri());
 
-            tempResource = OCPlatform::constructResourceObject(host, uri, CT_ADAPTER_IP, true,
-                    oit->getResourceTypes(), m_if);
+            try
+            {
+                tempResource = OCPlatform::constructResourceObject(host, uri, CT_ADAPTER_IP, true,
+                        oit->getResourceTypes(), m_if);
 
-            p_resources.push_back(tempResource);
+                p_resources.push_back(tempResource);
+            } catch (std::exception& e)
+            {
+                std::cout << "Exception: " << e.what() << std::endl;
+            }
         }
 
         // Send GET messages to the child resources in turn.