Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
a few smells in java
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Mon, 20 Jun 2016 19:43:27 +0000 (21:43 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Mon, 20 Jun 2016 19:43:27 +0000 (21:43 +0200)
examples/java/app/bittorrent/Main.java
examples/java/app/masterworker/Worker.java
examples/java/dht/kademlia/Bucket.java
teshsuite/java/SemaphoreGC/SemaphoreGC.java

index 021b1c5..8c7fb2c 100644 (file)
@@ -18,7 +18,7 @@ class Main{
     Msg.init(args);
     if(args.length < 2) {
       Msg.info("Usage   : Bittorrent platform_file deployment_file");
-      Msg.info("example : Bittorrent ../platforms/platform.xml bittorrent.xml");
+      Msg.info("example : Bittorrent ../platforms/cluster.xml bittorrent.xml");
       System.exit(1);
     }
 
@@ -27,6 +27,6 @@ class Main{
     Msg.deployApplication(args[1]);
 
     /*  execute the simulation. */
-        Msg.run();
+    Msg.run();
   }
 }
index 4236ebd..dc7d44f 100644 (file)
@@ -31,7 +31,7 @@ public class Worker extends Process {
     while(true) {  
       Task task = Task.receive("worker_"+num);
 
-      if (task.getName().equals("finalize")) {
+      if ("finalize".equals(task.getName())) {
         break;
       }
       Msg.info("Received \"" + task.getName() +  "\". Processing it.");
index 51f6712..1abceb1 100644 (file)
@@ -12,7 +12,7 @@ public class Bucket {
   private int id;
 
   public Bucket(int id) {
-    this.nodes = new ArrayList<Integer>();
+    this.nodes = new ArrayList<>();
     this.id = id;
   }
 
@@ -46,8 +46,8 @@ public class Bucket {
 
   /* Add the content of the bucket into a answer object. */
   public void addToAnswer(Answer answer, int destination) {
-    for (int id : this.nodes) {
-      answer.getNodes().add(new Contact(id,id ^ destination));
+    for (int nodeId : this.nodes) {
+      answer.getNodes().add(new Contact(nodeId,nodeId ^ destination));
     }
   }
 
index 84d4f18..3939f28 100644 (file)
@@ -24,7 +24,7 @@ class SemCreator extends Process {
     Msg.info("Creating 50 new Semaphores, yielding and triggering a GC after each");
     for(j = 1; j <= 50; j++) {
       sem = new Semaphore(0);
-      waitFor(10); 
+      waitFor(10);
       System.gc();
     }
     Msg.info("It worked, we survived. The test is passed.");
@@ -32,6 +32,10 @@ class SemCreator extends Process {
 }
 
 public class SemaphoreGC {
+  private SemaphoreGC() {
+    throw new IllegalAccessError("Utility class");
+  }
+
   public static void main(String[] args) throws Exception {
     Msg.init(args);
     if (args.length < 1) {