Updating the first benchmark with new stubs/skeletons; somehow motion detection is...
[iot2.git] / iotjava / iotrmi / Java / IoTRMIComm.java
index 16f84cb1d52a51bfad2e3e1d35efddf92ddcdf59..b3cc9f507be373e18ffa8925c0cc14809dd05931 100644 (file)
@@ -95,7 +95,7 @@ public abstract class IoTRMIComm {
                                        // Take the current method from the queue and wake up the correct thread
                                        retValueBytes = returnQueue.poll();
                                        if (retValueBytes != null) {    // If there is method bytes
-                                               System.out.println("retValBytes in wake up thread: " + Arrays.toString(retValueBytes));
+                                               //System.out.println("retValBytes in wake up thread: " + Arrays.toString(retValueBytes));
                                                int objectId = getObjectId(retValueBytes);
                                                int methodId = getMethodId(retValueBytes);
                                                String strKey = objectId + "-" + methodId;
@@ -401,11 +401,23 @@ public abstract class IoTRMIComm {
                // Receive return value and return it to caller
                // Now just strip off the object ID and method ID
                int headerLen = IoTRMIUtil.OBJECT_ID_LEN + IoTRMIUtil.METHOD_ID_LEN + IoTRMIUtil.PACKET_TYPE_LEN;
+               //if (retValueBytes == null)
+               //      System.out.println("retValueBytes is null!");
+
                int valByteLen = retValueBytes.length - headerLen;
                byte[] retValBytes = new byte[valByteLen];
                // Method Id is positioned after object Id in the byte array
-               System.arraycopy(retValueBytes, headerLen, retValBytes, 0, valByteLen);
-               Object retObj = IoTRMIUtil.getParamObject(retType, retGenTypeVal, retValBytes);
+
+               //System.out.println("Val byte len: " + valByteLen);
+               //System.out.println("Length retValBytes: " + retValBytes.length);
+
+               //System.arraycopy(retValueBytes, headerLen, retValBytes, 0, valByteLen);
+               //Object retObj = IoTRMIUtil.getParamObject(retType, retGenTypeVal, retValBytes);
+               Object retObj = null;
+               if (valByteLen != 0) {
+                       System.arraycopy(retValueBytes, headerLen, retValBytes, 0, valByteLen);
+                       retObj = IoTRMIUtil.getParamObject(retType, retGenTypeVal, retValBytes);
+               }
                // This means the right object and method have gotten the return value, so we set this back to false
                return retObj;
        }