From: Sandeep Sharma Date: Fri, 7 Oct 2016 12:52:55 +0000 (+0530) Subject: Fixed [IOT-1414] X-Git-Tag: 1.3.0~1055^2~93 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=eeeefea7b4974220c03544a623a7ff9168a72a0f;p=platform%2Fupstream%2Fiotivity.git Fixed [IOT-1414] Propagate INVALID_CALLBACK instead of INVALID_PARAM when Listener is null Change-Id: Id41c9be5dc33e9220c4809351b8269738eb95f56 Signed-off-by: Sandeep Sharma Reviewed-on: https://gerrit.iotivity.org/gerrit/12949 Tested-by: jenkins-iotivity Reviewed-by: Randeep Singh (cherry picked from commit dc57a68c8a4eceb0efdf6786d48ce42f76305d8e) Reviewed-on: https://gerrit.iotivity.org/gerrit/13015 --- diff --git a/android/android_api/base/jni/JniOcCloudProvisioning.cpp b/android/android_api/base/jni/JniOcCloudProvisioning.cpp index 72f94de..c1bac6a 100644 --- a/android/android_api/base/jni/JniOcCloudProvisioning.cpp +++ b/android/android_api/base/jni/JniOcCloudProvisioning.cpp @@ -271,7 +271,7 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcCloudProvisioning_requestCertifi LOGD("OcCloudProvisioning_requestCertificate"); if (!jListener) { - ThrowOcException(OC_STACK_INVALID_PARAM, "Listener cannot be null"); + ThrowOcException(OC_STACK_INVALID_CALLBACK, "Listener cannot be null"); return; } @@ -314,12 +314,17 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcCloudProvisioning_getAclIdByDevi (JNIEnv *env, jobject thiz, jstring jdeviceId, jobject jListener) { LOGD("OcCloudProvisioning_getAclIdByDevice"); - if (!jListener || !jdeviceId) + if (!jListener) { - ThrowOcException(OC_STACK_INVALID_PARAM, "Listener and deviceID cannot be null"); + ThrowOcException(OC_STACK_INVALID_CALLBACK, "Listener cannot be null"); return; } + if (!jdeviceId) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "deviceID can not be null"); + return; + } JniOcCloudProvisioning *cloud = JniOcCloudProvisioning::getJniOcCloudProvisioningPtr(env, thiz); if (!cloud) { @@ -368,9 +373,14 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcCloudProvisioning_getIndividualA (JNIEnv *env, jobject thiz, jstring jaclID, jobject jListener) { LOGD("OcCloudProvisioning_getIndividualAclInfo"); - if (!jListener || !jaclID) + if (!jListener) { - ThrowOcException(OC_STACK_INVALID_PARAM, "Listener/aclID cannot be null"); + ThrowOcException(OC_STACK_INVALID_CALLBACK, "Listener cannot be null"); + return; + } + if (!jaclID) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "aclID cannot be null"); return; } @@ -419,7 +429,7 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcCloudProvisioning_getCRL LOGD("OcCloudProvisioning_getCRL"); if (!jListener) { - ThrowOcException(OC_STACK_INVALID_PARAM, "Listener cannot be null"); + ThrowOcException(OC_STACK_INVALID_CALLBACK, "Listener cannot be null"); return; } @@ -463,7 +473,12 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcCloudProvisioning_postCRL0 jobjectArray jserialnumArray, jobject jListener) { LOGD("OcCloudProvisioning_postCRL0"); - if (!jListener || !jthisUpdate || !jnextUpdate || !jserialnumArray) + if (!jListener) + { + ThrowOcException(OC_STACK_INVALID_CALLBACK,"Listener can not be null"); + return; + } + if (!jthisUpdate || !jnextUpdate || !jserialnumArray) { ThrowOcException(OC_STACK_INVALID_PARAM, " Invalid parameter (NULL param)"); return; diff --git a/android/android_api/base/jni/JniOcSecureResource.cpp b/android/android_api/base/jni/JniOcSecureResource.cpp index b01059e..e36bacb 100644 --- a/android/android_api/base/jni/JniOcSecureResource.cpp +++ b/android/android_api/base/jni/JniOcSecureResource.cpp @@ -591,7 +591,7 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcSecureResource_unlinkDevices #if defined(__WITH_X509__) || defined(__WITH_TLS__) if (!jListener) { - ThrowOcException(OC_STACK_INVALID_PARAM, "provisionTrustCertChainListener cannot be null"); + ThrowOcException(OC_STACK_INVALID_CALLBACK, "provisionTrustCertChainListener cannot be null"); return; }