Fixed ConcurrentModificationException

This commit is contained in:
felipeal
2012-07-30 20:42:22 +00:00
parent d3d36a3d89
commit 4713e53e29

View File

@@ -21,6 +21,9 @@ import com.google.appengine.api.channel.ChannelMessage;
import com.google.appengine.api.channel.ChannelServiceFactory; import com.google.appengine.api.channel.ChannelServiceFactory;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.logging.Logger; import java.util.logging.Logger;
import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServlet;
@@ -92,8 +95,9 @@ public class SendServlet extends HttpServlet {
boolean reqDebug = "1".equals(reqInfo.getParameter("debug")); boolean reqDebug = "1".equals(reqInfo.getParameter("debug"));
int ac2dmCnt = 0; int ac2dmCnt = 0;
Iterator<DeviceInfo> iterator = reqInfo.devices.iterator();
for (DeviceInfo deviceInfo : reqInfo.devices) { while (iterator.hasNext()) {
DeviceInfo deviceInfo = iterator.next();
if ("ac2dm".equals(deviceInfo.getType())) { if ("ac2dm".equals(deviceInfo.getType())) {
ac2dmCnt++; ac2dmCnt++;
} }
@@ -130,7 +134,7 @@ public class SendServlet extends HttpServlet {
if ("InvalidRegistration".equals(ex.getMessage())) { if ("InvalidRegistration".equals(ex.getMessage())) {
// Prune device, it no longer works // Prune device, it no longer works
reqInfo.deleteRegistration(deviceInfo.getDeviceRegistrationID()); reqInfo.deleteRegistration(deviceInfo.getDeviceRegistrationID());
reqInfo.devices.remove(deviceInfo); iterator.remove();
ac2dmCnt--; ac2dmCnt--;
} else { } else {
throw ex; throw ex;