@Override public void handle(Incident incident) throws Exception { synchronized (incidents) { boolean unique = true; Iterator<Incident> iter = incidents.iterator(); while (iter.hasNext()) { if (Strings.areEqual(iter.next().getLocation(), incident.getLocation())) { iter.remove(); unique = false; } } incidents.add(0, incident); numIncidents.inc(); if (unique) { numUniqueIncidents.inc(); } while (incidents.size() > maxErrors) { incidents.remove(incidents.size() - 1); } } }