Author: toad
Date: 2008-07-25 21:59:28 +0000 (Fri, 25 Jul 2008)
New Revision: 21403

Modified:
   branches/db4o/freenet/src/freenet/client/async/SingleFileFetcher.java
Log:
Clear metadata before throwing FetchException. Also synchronization related to 
clearing metadata (I think this may be unnecessary).
Significant performance gain, which suggests we have a leak related to 
allRequestByClientRequest.

Modified: branches/db4o/freenet/src/freenet/client/async/SingleFileFetcher.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/SingleFileFetcher.java       
2008-07-25 21:57:50 UTC (rev 21402)
+++ branches/db4o/freenet/src/freenet/client/async/SingleFileFetcher.java       
2008-07-25 21:59:28 UTC (rev 21403)
@@ -526,6 +526,7 @@
                                        container.set(this);
                                }
                                // All done! No longer our problem!
+                               metadata = null; // Get rid just in case we 
stick around somehow.
                                return;
                        } else if(metadata.isSplitfile()) {
                                if(logMINOR) Logger.minor(this, "Fetching 
splitfile");
@@ -551,7 +552,10 @@

                                if(metaStrings.isEmpty() && isFinal && mimeType 
!= null && ctx.allowedMIMETypes != null &&
                                                
!ctx.allowedMIMETypes.contains(mimeType)) {
-                                       throw new 
FetchException(FetchException.WRONG_MIME_TYPE, 
metadata.uncompressedDataLength(), false, clientMetadata.getMIMEType());
+                                       // Just in case...
+                                       long len = 
metadata.uncompressedDataLength();
+                                       metadata = null;
+                                       throw new 
FetchException(FetchException.WRONG_MIME_TYPE, len, false, 
clientMetadata.getMIMEType());
                                }

                                // Splitfile (possibly compressed)
@@ -579,6 +583,8 @@
                                                        tryURI = 
tryURI.dropLastMetaStrings(metaStrings.size());
                                                        rcb.onFailure(new 
FetchException(FetchException.TOO_MANY_PATH_COMPONENTS, 
metadata.uncompressedDataLength(), (rcb == parent), 
clientMetadata.getMIMEType(), tryURI), this, container, context);
                                                }
+                                               // Just in case...
+                                               metadata = null;
                                                return;
                                        }
                                } else
@@ -590,8 +596,10 @@

                                if((len > ctx.maxOutputLength) ||
                                                (len > ctx.maxTempLength)) {
-                                       
-                                       throw new 
FetchException(FetchException.TOO_BIG, len, isFinal && decompressors.size() <= 
(metadata.isCompressed() ? 1 : 0), clientMetadata.getMIMEType());
+                                       // Just in case...
+                                       boolean compressed = 
metadata.isCompressed();
+                                       metadata = null;
+                                       throw new 
FetchException(FetchException.TOO_BIG, len, isFinal && decompressors.size() <= 
(compressed ? 1 : 0), clientMetadata.getMIMEType());
                                }

                                SplitFileFetcher sf = new 
SplitFileFetcher(metadata, rcb, parent, ctx, 
@@ -777,7 +785,10 @@
                        if(persistent)
                                container.activate(SingleFileFetcher.this, 1);
                        try {
-                               metadata = 
Metadata.construct(result.asBucket());
+                               Metadata meta = 
Metadata.construct(result.asBucket());
+                               synchronized(SingleFileFetcher.this) {
+                                       metadata = meta;
+                               }
                                if(persistent)
                                        container.set(SingleFileFetcher.this);
                        } catch (MetadataParseException e) {


Reply via email to