Author: toad
Date: 2007-08-11 17:09:31 +0000 (Sat, 11 Aug 2007)
New Revision: 14616
Modified:
trunk/freenet/src/freenet/client/async/SingleFileFetcher.java
Log:
Break out of the lock either by throwing a FetchException or by scheduling a
job in the case of success.
In the latter case this is a good idea anyway...
Modified: trunk/freenet/src/freenet/client/async/SingleFileFetcher.java
===================================================================
--- trunk/freenet/src/freenet/client/async/SingleFileFetcher.java
2007-08-11 16:50:53 UTC (rev 14615)
+++ trunk/freenet/src/freenet/client/async/SingleFileFetcher.java
2007-08-11 17:09:31 UTC (rev 14616)
@@ -297,8 +297,7 @@
clientMetadata.mergeNoOverwrite(metadata.getClientMetadata());
if(metaStrings.isEmpty() && isFinal &&
clientMetadata.getMIMETypeNoParams() != null && ctx.allowedMIMETypes != null &&
!ctx.allowedMIMETypes.contains(clientMetadata.getMIMETypeNoParams())) {
- onFailure(new
FetchException(FetchException.WRONG_MIME_TYPE, -1, false,
clientMetadata.getMIMEType()));
- return;
+ throw new
FetchException(FetchException.WRONG_MIME_TYPE, -1, false,
clientMetadata.getMIMEType());
}
// Fetch it from the archive
if(ah == null)
@@ -308,7 +307,7 @@
Bucket dataBucket = ah.get(filename, actx,
null, recursionLevel+1, true);
if(dataBucket != null) {
if(logMINOR) Logger.minor(this,
"Returning data");
- Bucket out;
+ final Bucket out;
try {
// Data will not be freed until
client is finished with it.
if(returnBucket != null) {
@@ -319,11 +318,15 @@
out = dataBucket;
}
} catch (IOException e) {
- onFailure(new
FetchException(FetchException.BUCKET_ERROR));
- return;
+ throw new
FetchException(FetchException.BUCKET_ERROR);
}
// Return the data
- onSuccess(new
FetchResult(this.clientMetadata, out));
+ ctx.executor.execute(new Runnable() {
+ public void run() {
+ onSuccess(new
FetchResult(clientMetadata, out));
+ }
+ }, "SingleFileFetcher onSuccess
callback for "+this);
+
return;
} else {
if(logMINOR) Logger.minor(this,
"Fetching archive (thisKey="+thisKey+ ')');
@@ -384,8 +387,7 @@
if(metaStrings.isEmpty() && isFinal && mimeType
!= null && ctx.allowedMIMETypes != null &&
!ctx.allowedMIMETypes.contains(mimeType)) {
- onFailure(new
FetchException(FetchException.WRONG_MIME_TYPE, -1, false,
clientMetadata.getMIMEType()));
- return;
+ throw new
FetchException(FetchException.WRONG_MIME_TYPE, -1, false,
clientMetadata.getMIMEType());
}
// Simple redirect
@@ -444,8 +446,7 @@
if(metaStrings.isEmpty() && isFinal && mimeType
!= null && ctx.allowedMIMETypes != null &&
!ctx.allowedMIMETypes.contains(mimeType)) {
- onFailure(new
FetchException(FetchException.WRONG_MIME_TYPE,
metadata.uncompressedDataLength(), false, clientMetadata.getMIMEType()));
- return;
+ throw new
FetchException(FetchException.WRONG_MIME_TYPE,
metadata.uncompressedDataLength(), false, clientMetadata.getMIMEType());
}
// Splitfile (possibly compressed)
@@ -483,8 +484,7 @@
if((len > ctx.maxOutputLength) ||
(len > ctx.maxTempLength)) {
- onFailure(new
FetchException(FetchException.TOO_BIG, len, isFinal && decompressors.size() <=
(metadata.isCompressed() ? 1 : 0), clientMetadata.getMIMEType()));
- return;
+ throw new
FetchException(FetchException.TOO_BIG, len, isFinal && decompressors.size() <=
(metadata.isCompressed() ? 1 : 0), clientMetadata.getMIMEType());
}
SplitFileFetcher sf = new
SplitFileFetcher(metadata, rcb, parent, ctx,