r27136 - trunk/freenet/src/freenet/support/io

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

Modified:
   trunk/freenet/src/freenet/support/io/PersistentBlobTempBucket.java
Log:
Check for closed

Modified: trunk/freenet/src/freenet/support/io/PersistentBlobTempBucket.java
===================================================================
--- trunk/freenet/src/freenet/support/io/PersistentBlobTempBucket.java	2009-04-21 07:55:08 UTC (rev 27135)
+++ trunk/freenet/src/freenet/support/io/PersistentBlobTempBucket.java	2009-04-21 07:55:31 UTC (rev 27136)
@@ -88,6 +88,8 @@
 			
 			@Override
 			public int read() throws IOException {
+				if (closed) throw new IOException("closed");
+				
 				byte[] buf = new byte[1];
 				int res = read(buf);
 				if(res == -1) return -1;
@@ -96,6 +98,8 @@
 			
 			@Override
 			public int read(byte[] buffer, int bufOffset, int length) throws IOException {
+				if (closed) throw new IOException("closed");
+				
 				long max;
 				synchronized(PersistentBlobTempBucket.this) {
 					if(freed) throw new IOException("Bucket freed during read");
@@ -115,6 +119,7 @@
 			
 			@Override
 			public int read(byte[] buffer) throws IOException {
+				if (closed) throw new IOException("closed");
 				return read(buffer, 0, buffer.length);
 			}
 			
@@ -125,12 +130,13 @@
 			
 			@Override
 			public void close() {
+				closed = true;
+				
 				synchronized(PersistentBlobTempBucket.this) {
 					inputStreams--;
 				}
 				// Do nothing.
 			}
-			
 		};
 	}