package controllers;

import models.Panic;
import play.Logger;
import play.Play;
import play.jobs.Every;
import play.jobs.Job;

/**
 * @author Michael Ruf
 * @since 2015-11-28
 */
@Every("1s")
@SuppressWarnings("unused")
public class CleanPanicsJob extends Job {

    @Override
    public void doJob() throws Exception {
        super.doJob();

        long timeLimit = Long.parseLong(Play.configuration.getProperty("panic.ttl"));
        Logger.debug("CleanPanicsJob: Start for time limit: " + timeLimit);

        for (Panic panic : Application.panics) {
            if (Panic.getPanicTime() - panic.getTime() > timeLimit) {
                Application.panics.remove(panic);
            }
        }
    }
}

@@ -121,16 +121,44 @@
 s.Job;%0A%0A
+import java.util.Iterator;%0A%0A
 /**%0A * @
@@ -285,16 +285,111 @@
  Job %7B%0A%0A
+    @SuppressWarnings(%22ForLoopReplaceableByForEach%22) // due to ConcurrentModificationException%0A
     @Ove
@@ -641,43 +641,132 @@
 or (
-Panic panic : Application.panics) %7B
+Iterator%3CPanic%3E iterator = Application.panics.iterator(); iterator.hasNext(); ) %7B%0A            Panic panic = iterator.next();
 %0A   
@@ -852,34 +852,24 @@
     
-Application.panics
+iterator
 .remove(
 pani
@@ -864,21 +864,16 @@
 .remove(
-panic
 );%0A     

Fix concurrent modification exception