r27137 - trunk/freenet/src/freenet/support/io

[email protected] Tue, 21 Apr 2009 07:55:53 +0000
Newsgroups gmane.network.freenet.cvs
Message-ID <[email protected]>
Author: j16sdiz
Date: 2009-04-21 07:55:52 +0000 (Tue, 21 Apr 2009)
New Revision: 27137

Modified:
   trunk/freenet/src/freenet/support/io/PersistentBlobTempBucket.java
Log:
Fix inputStream count

Modified: trunk/freenet/src/freenet/support/io/PersistentBlobTempBucket.java
===================================================================
--- trunk/freenet/src/freenet/support/io/PersistentBlobTempBucket.java	2009-04-21 07:55:31 UTC (rev 27136)
+++ trunk/freenet/src/freenet/support/io/PersistentBlobTempBucket.java	2009-04-21 07:55:52 UTC (rev 27137)
@@ -75,17 +75,15 @@
 	public InputStream getInputStream() throws IOException {
 		if(freed) throw new IOException("Already freed");
 		final FileChannel channel = factory.channel;
+		
+		synchronized(PersistentBlobTempBucket.this) {
+			inputStreams++;
+		}
+		
 		return new InputStream() {
-
 			private int offset;
 			private boolean closed;
 			
-			{
-				synchronized(PersistentBlobTempBucket.this) {
-					inputStreams++;
-				}
-			}
-			
 			@Override
 			public int read() throws IOException {
 				if (closed) throw new IOException("closed");
@@ -130,6 +128,7 @@
 			
 			@Override
 			public void close() {
+				if (closed) return;
 				closed = true;
 				
 				synchronized(PersistentBlobTempBucket.this) {