You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@synapse.apache.org by as...@apache.org on 2007/05/17 10:23:56 UTC

svn commit: r538828 - /webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/statistics/impl/EndPointStatisticsStack.java

Author: asankha
Date: Thu May 17 01:23:55 2007
New Revision: 538828

URL: http://svn.apache.org/viewvc?view=rev&rev=538828
Log:
fix concurrent modification exception during statistics reporting

Modified:
    webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/statistics/impl/EndPointStatisticsStack.java

Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/statistics/impl/EndPointStatisticsStack.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/statistics/impl/EndPointStatisticsStack.java?view=diff&rev=538828&r1=538827&r2=538828
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/statistics/impl/EndPointStatisticsStack.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/statistics/impl/EndPointStatisticsStack.java Thu May 17 01:23:55 2007
@@ -22,6 +22,7 @@
 import org.apache.synapse.statistics.StatisticsCollector;
 import java.util.Iterator;
 import java.util.ArrayList;
+import java.util.List;
 
 /**
  * The data structure to hold statistics related to the endpoints
@@ -93,8 +94,13 @@
     public void reportToStatisticsCollector(StatisticsCollector statisticsCollector,
                                             boolean isFault, String name) {
         if (endpointStatistics != null && !endpointStatistics.isEmpty()) {
+
+            List tobeRemoved = new ArrayList();
+
             for (Iterator epIterator = endpointStatistics.iterator();
                  epIterator.hasNext();) {
+                System.out.println(Thread.currentThread().getName());
+                Thread.dumpStack();
                 Object statisticsObj = epIterator.next();
                 if (statisticsObj instanceof EndPointStatistics) {
                     EndPointStatistics statistics = (EndPointStatistics) statisticsObj;
@@ -112,11 +118,13 @@
                             statisticsCollector.reportForEndPoint(statistics.endPointName,
                                     true, statistics.inTimeForOutFlow,
                                     System.currentTimeMillis(), isFault);
-                            endpointStatistics.remove(statistics);
+                            tobeRemoved.add(statistics);
                         }
                     }
                 }
             }
+
+            endpointStatistics.removeAll(tobeRemoved);
         }
     }
 
@@ -175,6 +183,22 @@
                 isStatisticsEnable = statisticsEnable;
                 isFault = fault;
             }
+        }
+
+        public boolean equals(Object o) {
+            if (this == o) return true;
+            if (o == null || getClass() != o.getClass()) return false;
+
+            EndPointStatistics that = (EndPointStatistics) o;
+
+            if (endPointName != null ? !endPointName.equals(that.endPointName) : that.endPointName != null)
+                return false;
+
+            return true;
+        }
+
+        public int hashCode() {
+            return (endPointName != null ? endPointName.hashCode() : 0);
         }
     }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: synapse-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: synapse-dev-help@ws.apache.org