Throw OcException for invalid (null) parameters in Java Layer of android_api.
authorLarry Sachs <larry.j.sachs@intel.com>
Fri, 16 Sep 2016 17:22:28 +0000 (10:22 -0700)
committerRick Bell <richard.s.bell@intel.com>
Wed, 28 Sep 2016 23:47:24 +0000 (23:47 +0000)
[IOT-1254] -- OcPlatform.notifyListOfObservers() ocObservationIdList is null.
[IOT-1255] -- OcResource.observe() observeType is null.
[IOT-1256] -- OcPlatform.bindResources() ocResourceHandleList is null.
[IOT-1257] -- OcPlatform.unbindResources() ocResourceHandleList is null.

Change-Id: Ib1c20dba6d0e85a05e8099ba1276d65334560c9d
Signed-off-by: Larry Sachs <larry.j.sachs@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/11875
Reviewed-by: George Nash <george.nash@intel.com>
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Rick Bell <richard.s.bell@intel.com>
android/android_api/base/src/main/java/org/iotivity/base/OcPlatform.java
android/android_api/base/src/main/java/org/iotivity/base/OcResource.java

index f699e16..589bdf1 100644 (file)
@@ -172,6 +172,10 @@ public final class OcPlatform {
             OcResourceResponse ocResourceResponse) throws OcException {
         OcPlatform.initCheck();
 
+        if (ocObservationIdList == null) {
+            throw new OcException(ErrorCode.INVALID_PARAM, "ocObservationIdList cannot be null");
+        }
+
         byte[] idArr = new byte[ocObservationIdList.size()];
         Iterator<Byte> it = ocObservationIdList.iterator();
         int i = 0;
@@ -211,6 +215,10 @@ public final class OcPlatform {
             QualityOfService qualityOfService) throws OcException {
         OcPlatform.initCheck();
 
+        if (ocObservationIdList == null) {
+            throw new OcException(ErrorCode.INVALID_PARAM, "ocObservationIdList cannot be null");
+        }
+
         byte[] idArr = new byte[ocObservationIdList.size()];
         Iterator<Byte> it = ocObservationIdList.iterator();
         int i = 0;
@@ -631,6 +639,11 @@ public final class OcPlatform {
             OcResourceHandle ocResourceCollectionHandle,
             List<OcResourceHandle> ocResourceHandleList) throws OcException {
         OcPlatform.initCheck();
+
+        if (ocResourceHandleList == null) {
+            throw new OcException(ErrorCode.INVALID_PARAM, "ocResourceHandleList cannot be null");
+        }
+
         OcPlatform.bindResources0(
                 ocResourceCollectionHandle,
                 ocResourceHandleList.toArray(
@@ -672,6 +685,11 @@ public final class OcPlatform {
             OcResourceHandle ocResourceCollectionHandle,
             List<OcResourceHandle> ocResourceHandleList) throws OcException {
         OcPlatform.initCheck();
+
+        if (ocResourceHandleList == null) {
+            throw new OcException(ErrorCode.INVALID_PARAM, "ocResourceHandleList cannot be null");
+        }
+
         OcPlatform.unbindResources0(
                 ocResourceCollectionHandle,
                 ocResourceHandleList.toArray(
index 34d7c41..c0fd090 100644 (file)
@@ -370,6 +370,11 @@ public class OcResource {
     public void observe(ObserveType observeType,
                         Map<String, String> queryParamsMap,
                         OnObserveListener onObserveListener) throws OcException {
+
+        if (observeType == null) {
+            throw new OcException(ErrorCode.INVALID_PARAM, "observeType cannot be null");
+        }
+
         this.observe(
                 observeType.getValue(),
                 queryParamsMap,