/**
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package tools.descartes.teastore.registry.rest;

import java.util.Iterator;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Daemon which sends out heartbeats to the resistered service.
 * 
 * @author Simon
 */
public class RegistryHeartbeatDaemon implements Runnable {
	private static final Logger LOG = LoggerFactory.getLogger(RegistryHeartbeatDaemon.class);

	@Override
	public void run() {
		try {
			Registry.getRegistryInstance().getMap().entrySet().stream().forEach(entry -> {
				for (Iterator<String> iter = entry.getValue().iterator(); iter.hasNext();) {
					String location = iter.next();
					if (!Registry.getRegistryInstance().isAlive(entry.getKey(), location)) {
						iter.remove();
						LOG.warn("Removed " + entry.getKey() + "@" + location + " since it failed the heartbeat!");
					}
				}
			});
		} catch (Exception e) {
			e.printStackTrace();
			throw new RuntimeException(e);
		}
	}
}

@@ -689,16 +689,68 @@
 Factory;
+%0Aimport java.util.LinkedList;%0Aimport java.util.List;
 %0A%0A/**%0A *
@@ -1112,17 +1112,84 @@
 -%3E %7B%0A%09%09%09
-%09
+  List%3CString%3E copy = new LinkedList%3CString%3E(entry.getValue())%0A%09%09%09  
 for (Ite
@@ -1209,32 +1209,20 @@
  iter = 
-entry.getValue()
+copy
 .iterato

work on issue #115