Fix a logic to filter out an exception in createRemoteEnrollee API for Android
authorJihun Ha <jihun.ha@samsung.com>
Mon, 5 Sep 2016 05:54:36 +0000 (14:54 +0900)
committerUze Choi <uzchoi@samsung.com>
Tue, 6 Sep 2016 10:36:24 +0000 (10:36 +0000)
If a resource does not have a "oic.wk.prov" resource type, createRemoteEnrollee
API should return a NULL pointer. However, this exception has not been
handled in jni implementation. To resolve this problem, this patch make
this exception returned to android layer, properly.

Change-Id: I70d9dfbcd6cd21757e4f594abbc99902dc367681
Signed-off-by: Jihun Ha <jihun.ha@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/11395
Reviewed-by: Jongho Park <jh8397.park@samsung.com>
Reviewed-by: Sijae Kim <sijae.kim@samsung.com>
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/jni/JniEasySetup.cpp

index cae9ec5..6d2216d 100755 (executable)
@@ -54,6 +54,12 @@ Java_org_iotivity_service_easysetup_mediator_EasySetup_nativeCreateRemoteEnrolle
     try
     {
         nativeRemoteEnrollee = EasySetup::getInstance()->createRemoteEnrollee(jniOcResource->getOCResource());
+        if (!nativeRemoteEnrollee)
+        {
+            ES_LOGE("Failed to create RemoteEnrollee object.");
+            return NULL;
+        }
+
         //create the java object
         jRemoteEnrollee = env->NewObject(g_cls_RemoteEnrollee, g_mid_RemoteEnrollee_ctor);
         if (!jRemoteEnrollee)