Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
sonar cleanups
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Thu, 24 Jan 2019 07:06:26 +0000 (08:06 +0100)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Thu, 24 Jan 2019 07:06:31 +0000 (08:06 +0100)
- kill dead code
- stick to Java variable naming convention
- prefer isEmpty() to size()==0

src/bindings/java/JavaContext.cpp
src/bindings/java/jmsg.cpp
src/bindings/java/org/simgrid/msg/Process.java

index 7adaaaa..99642af 100644 (file)
@@ -75,8 +75,7 @@ void JavaContext::stop_hook()
        * until run_jprocess(), IIUC.
        */
       jxbt_throw_by_name(env, "org/simgrid/msg/ProcessKilledError", "Process killed");
-      // XBT_ERROR("Cannot detach the current thread");
-      // simgrid::xbt::Backtrace().display();
+      XBT_DEBUG("Cannot detach the current thread");
     }
 }
 
index 4ecd54e..528510a 100644 (file)
@@ -270,7 +270,6 @@ static void run_jprocess(JNIEnv *env, jobject jprocess)
     env->ExceptionClear();
     XBT_ATTRIB_UNUSED jint error = __java_vm->DetachCurrentThread();
     xbt_assert(error == JNI_OK, "Cannot detach failing thread");
-    // simgrid::xbt::Backtrace().display();
     simgrid::kernel::context::throw_stoprequest();
   }
 }
index 0fb5c6f..d8de151 100644 (file)
@@ -303,11 +303,7 @@ public abstract class Process implements Runnable {
                        Msg.info("Unexpected behavior. Stopping now");
                        System.exit(1);
                }
-               catch(ProcessKilledError pk) {
-                       /* The process was killed before its end. With a kill() or something. */
-                       //Msg.info("Forwarding a PKE");
-                       throw pk;
-               }       
+               /* Let the ProcessKilledError (that we'd get if the process is forcefully killed) flow back to the caller */
        }
 
        /**
@@ -350,12 +346,12 @@ public abstract class Process implements Runnable {
                 if (! t.isDaemon() && !t.getName().equals("main"))
                     ids.add(t.getId());
             }
-            if (ids.size() > 0) {
-               long[] id_array = new long[ids.size()];
+            if (! ids.isEmpty()) {
+               long[] idArray = new long[ids.size()];
                for (int i=0; i<ids.size(); i++) 
-                       id_array[i] = ids.get(i);
+                       idArray[i] = ids.get(i);
 
-                final ThreadInfo[] threadInfos = threadMXBean.getThreadInfo(id_array, true, true);
+                final ThreadInfo[] threadInfos = threadMXBean.getThreadInfo(idArray, true, true);
                 final StringBuilder dump = new StringBuilder();
                 for (ThreadInfo threadInfo : threadInfos) {
                     dump.append('"');