Author: toad
Date: 2007-12-18 19:55:13 +0000 (Tue, 18 Dec 2007)
New Revision: 16698

Modified:
   trunk/freenet/src/freenet/client/async/ClientGetter.java
Log:
flush() before close(), but always close().
close() calls flush() but IGNORES ANY ERROR. If we want to hear about errors we 
must call flush() explicitly.

Modified: trunk/freenet/src/freenet/client/async/ClientGetter.java
===================================================================
--- trunk/freenet/src/freenet/client/async/ClientGetter.java    2007-12-18 
18:09:48 UTC (rev 16697)
+++ trunk/freenet/src/freenet/client/async/ClientGetter.java    2007-12-18 
19:55:13 UTC (rev 16698)
@@ -287,13 +287,23 @@
                if(binaryBlobKeysAddedAlready == null) return true;
                synchronized(binaryBlobKeysAddedAlready) {
                        if(binaryBlobStream == null) return true;
+                       boolean triedClose = false;
                        try {
                                BinaryBlob.writeEndBlob(binaryBlobStream);
+                               binaryBlobStream.flush();
+                               triedClose = true;
                                binaryBlobStream.close();
                                return true;
                        } catch (IOException e) {
                                Logger.error(this, "Failed to close binary blob 
stream: "+e, e);
                                onFailure(new 
FetchException(FetchException.BUCKET_ERROR, "Failed to close binary blob 
stream: "+e), null);
+                               if(!triedClose) {
+                                       try {
+                                               binaryBlobStream.close();
+                                       } catch (IOException e1) {
+                                               // Ignore
+                                       }
+                               }
                                return false;
                        } finally {
                                binaryBlobStream = null;


Reply via email to