Author: nextgens
Date: 2007-06-23 10:00:34 +0000 (Sat, 23 Jun 2007)
New Revision: 13727
Modified:
trunk/freenet/src/freenet/crypt/Yarrow.java
Log:
Yarrow: don't rely on the GC to close our streams if an exception is raised
Modified: trunk/freenet/src/freenet/crypt/Yarrow.java
===================================================================
--- trunk/freenet/src/freenet/crypt/Yarrow.java 2007-06-23 02:22:52 UTC (rev
13726)
+++ trunk/freenet/src/freenet/crypt/Yarrow.java 2007-06-23 10:00:34 UTC (rev
13727)
@@ -240,14 +240,26 @@
}
try {
- DataOutputStream dos =
- new DataOutputStream(new
BufferedOutputStream(new FileOutputStream(filename)));
- for (int i = 0; i < 32; i++)
- dos.writeLong(nextLong());
- dos.close();
- } catch (Exception e) {
- }
-
+ FileOutputStream fos = null;
+ BufferedOutputStream bos = null;
+ DataOutputStream dos = null;
+
+ try {
+ fos = new FileOutputStream(filename);
+ bos = new BufferedOutputStream(fos);
+ dos = new DataOutputStream(bos);
+
+ for (int i = 0; i < 32; i++)
+ dos.writeLong(nextLong());
+
+ }catch (IOException e) {
+ Logger.error(this, "IOE while saving the seed
file! : "+e.getMessage());
+ } finally {
+ if(dos != null) dos.close();
+ if(bos != null) bos.close();
+ if(fos != null) fos.close();
+ }
+ } catch (Exception e) {}
}
/**