Author: toad
Date: 2008-11-26 14:18:11 +0000 (Wed, 26 Nov 2008)
New Revision: 23875
Modified:
trunk/freenet/src/freenet/support/io/TempBucketFactory.java
Log:
Locking: Prevent saces' ConcurrentModificationException.
Modified: trunk/freenet/src/freenet/support/io/TempBucketFactory.java
===================================================================
--- trunk/freenet/src/freenet/support/io/TempBucketFactory.java 2008-11-26
12:07:56 UTC (rev 23874)
+++ trunk/freenet/src/freenet/support/io/TempBucketFactory.java 2008-11-26
14:18:11 UTC (rev 23875)
@@ -88,7 +88,13 @@
}
private void closeInputStreams(boolean forFree) {
- for(TempBucketInputStream is : tbis) {
+ TempBucketInputStream[] streams;
+ synchronized(this) {
+ streams = tbis.toArray(new
TempBucketInputStream[tbis.size()]);
+ if(forFree)
+ tbis.clear();
+ }
+ for(TempBucketInputStream is : streams) {
try {
if(forFree)
is.close();
@@ -96,7 +102,11 @@
is._maybeResetInputStream();
} catch(IOException e) {
Closer.close(is);
- tbis.remove(is);
+ if(!forFree) {
+ synchronized(this) {
+ tbis.remove(is);
+ }
+ }
}
}
}
_______________________________________________
cvs mailing list
[email protected]
http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs