dflorey 2004/03/29 04:30:47
Modified: src/share/org/apache/slide/event EventCollection.java
Log:
Added synchnonize blockes to avoid concurrent modification
Revision Changes Path
1.6 +23 -19
jakarta-slide/src/share/org/apache/slide/event/EventCollection.java
Index: EventCollection.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/share/org/apache/slide/event/EventCollection.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- EventCollection.java 15 Mar 2004 13:16:48 -0000 1.5
+++ EventCollection.java 29 Mar 2004 12:30:47 -0000 1.6
@@ -45,7 +45,9 @@
}
public void addEvent(AbstractEventMethod method, EventObject event) {
- collection.add(new Event(method, event));
+ synchronized ( collection ) {
+ collection.add(new Event(method, event));
+ }
}
public List getCollection() {
@@ -56,21 +58,23 @@
String NEWLINE = System.getProperty("line.separator");
StringBuffer buffer = new StringBuffer(256);
buffer.append(getClass().getName()).append("[collected events=");
- for ( Iterator i = collection.iterator(); i.hasNext(); ) {
- buffer.append(NEWLINE);
- Event event = (Event)i.next();
- if ( event.getEvent() instanceof RemoteInformation ) {
- StringBuffer infoBuffer = new StringBuffer();
- String[][] information =
((RemoteInformation)event.getEvent()).getInformation();
- boolean first = true;
- for ( int j = 0; j < information.length; j++ ) {
- if ( !first ) infoBuffer.append(", ");
- first = false;
-
infoBuffer.append(information[j][0]).append("=").append(information[j][1]);
+ synchronized ( collection ) {
+ for ( Iterator i = collection.iterator(); i.hasNext(); ) {
+ buffer.append(NEWLINE);
+ Event event = (Event)i.next();
+ if ( event.getEvent() instanceof RemoteInformation ) {
+ StringBuffer infoBuffer = new StringBuffer();
+ String[][] information =
((RemoteInformation)event.getEvent()).getInformation();
+ boolean first = true;
+ for ( int j = 0; j < information.length; j++ ) {
+ if ( !first ) infoBuffer.append(", ");
+ first = false;
+
infoBuffer.append(information[j][0]).append("=").append(information[j][1]);
+ }
+ buffer.append("["+event.getClass().getName()+"
[name="+event.getMethod().getId()+", information: "+infoBuffer.toString()+"]]");
+ } else {
+ buffer.append("["+event.getClass().getName()+"
[name="+event.getMethod().getId()+"]]");
}
- buffer.append("["+event.getClass().getName()+"
[name="+event.getMethod().getId()+", information: "+infoBuffer.toString()+"]]");
- } else {
- buffer.append("["+event.getClass().getName()+"
[name="+event.getMethod().getId()+"]]");
}
}
buffer.append("]");
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]