[vlma-devel] commit: Partial revert of d9033f875547ffd3921e753e78dece12af3444c7 to work around a ConcurrentModificationException . (Adrien Grand )
git version control
git at videolan.org
Wed May 21 20:21:50 CEST 2008
vlma | branch: master | Adrien Grand <jpountz at videolan.org> | Wed May 21 20:23:11 2008 +0200| [9ce15917611da8e8b7e09cc6d69b40e1a0e2e72f]
Partial revert of d9033f875547ffd3921e753e78dece12af3444c7 to work around a ConcurrentModificationException.
> http://git.videolan.org/gitweb.cgi/vlma.git/?a=commit;h=9ce15917611da8e8b7e09cc6d69b40e1a0e2e72f
---
.../src/main/java/org/videolan/vlma/DataImpl.java | 9 ++++++---
.../java/org/videolan/vlma/OrderGiverImpl.java | 12 ++++++++----
.../org/videolan/vlma/monitor/OrderMonitor.java | 10 +++++++---
3 files changed, 21 insertions(+), 10 deletions(-)
diff --git a/vlma-core/src/main/java/org/videolan/vlma/DataImpl.java b/vlma-core/src/main/java/org/videolan/vlma/DataImpl.java
index 601724b..37f9d32 100644
--- a/vlma-core/src/main/java/org/videolan/vlma/DataImpl.java
+++ b/vlma-core/src/main/java/org/videolan/vlma/DataImpl.java
@@ -33,6 +33,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -573,10 +574,12 @@ public class DataImpl implements Data {
}
logger.log(Level.DEBUG, "Got " + newMedias.size() + " channels");
- for (Media m : medias) {
- if (m.getClass().getName() == "SatChannel" && coverages.contains(((SatChannel)m).getCoverage()))
+ Iterator k = medias.iterator();
+ while (k.hasNext()) {
+ Media ch = (Media) k.next();
+ if (ch.getClass().getName() == "SatChannel" && coverages.contains(((SatChannel)ch).getCoverage()))
{
- medias.remove(m);
+ k.remove();
}
}
medias.addAll(newMedias);
diff --git a/vlma-core/src/main/java/org/videolan/vlma/OrderGiverImpl.java b/vlma-core/src/main/java/org/videolan/vlma/OrderGiverImpl.java
index 24c76eb..bffa04a 100644
--- a/vlma-core/src/main/java/org/videolan/vlma/OrderGiverImpl.java
+++ b/vlma-core/src/main/java/org/videolan/vlma/OrderGiverImpl.java
@@ -190,23 +190,27 @@ public class OrderGiverImpl implements OrderGiver {
}
logger.log(Level.DEBUG, oldOrders.size() + " former orders");
if (sameHashTypeGroupList != null) {
- for (MediaGroup g : sameHashTypeGroupList) {
+ Iterator<MediaGroup> groupIt = sameHashTypeGroupList.iterator();
+ while (groupIt.hasNext()) {
+ MediaGroup g = groupIt.next();
/*
* The groups that are already diffused are removed from
* the list. Their correspondant adpater are also
* removed from the list of ready adapters.
*/
- for (Order order : oldOrders) {
+ Iterator<Order> orderIt = oldOrders.iterator();
+ while (orderIt.hasNext()) {
+ Order order = orderIt.next();
logger.log(Level.DEBUG, g.medias.size() + " media against " + order.getMedias().medias.size() + " media");
if ((order.getMedias().medias.containsAll(g.medias))
&& (g.medias.containsAll(order.getMedias().medias))
&& (order.getAdapter().getServer().getIp() == g.medias.get(0).getProgram().getPlayer())) {
// Remove the mediaGroup
- sameHashTypeGroupList.remove(g);
+ groupIt.remove();
// Remove its correspondant adapter
sameHashTypeAdapterList.remove(order.getAdapter());
// Remove now the order
- oldOrders.remove(order);
+ orderIt.remove();
break;
}
}
diff --git a/vlma-core/src/main/java/org/videolan/vlma/monitor/OrderMonitor.java b/vlma-core/src/main/java/org/videolan/vlma/monitor/OrderMonitor.java
index 391f79c..a415853 100644
--- a/vlma-core/src/main/java/org/videolan/vlma/monitor/OrderMonitor.java
+++ b/vlma-core/src/main/java/org/videolan/vlma/monitor/OrderMonitor.java
@@ -21,6 +21,7 @@
package org.videolan.vlma.monitor;
import java.net.InetAddress;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -96,10 +97,13 @@ public class OrderMonitor implements Monitor {
program.setBroadcastState(false);
shouldCompute = true;
/* Remove the order of a non-diffused stream */
- for (List<Order> l : data.getOrders().values()) {
- for (Order o : l) {
+ Iterator<List<Order>> k = data.getOrders().values().iterator();
+ while (k.hasNext()) {
+ Iterator<Order> l = k.next().iterator();
+ while (l.hasNext()) {
+ Order o = l.next();
if (o.getMedias().medias.contains(media)) {
- l.remove(o);
+ l.remove();
break;
}
}
More information about the vlma-devel
mailing list