[MOBY-guts] biomoby commit

Eddie Kawas kawas at dev.open-bio.org
Thu Aug 13 21:26:26 UTC 2009


kawas
Thu Aug 13 17:26:26 EDT 2009
Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client
In directory dev.open-bio.org:/tmp/cvs-serv2055/src/main/org/biomoby/client

Modified Files:
	CentralDigestCachedSimpleImpl.java 
Log Message:
added a finally block to load/store that calls close() on the underlying file
moby-live/Java/src/main/org/biomoby/client CentralDigestCachedSimpleImpl.java,1.4,1.5
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/CentralDigestCachedSimpleImpl.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/CentralDigestCachedSimpleImpl.java	2008/10/30 02:33:25	1.4
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/CentralDigestCachedSimpleImpl.java	2009/08/13 21:26:26	1.5
@@ -319,13 +319,17 @@
 	throws MobyException {
 // 	File outputFile = new File (cache.getAbsolutePath() + File.separator + clean (name));
 	File outputFile = new File (cache.getAbsolutePath() + File.separator + name);
+	PrintWriter fileout = null;
 	try {
-	    PrintWriter fileout =
+	    fileout =
 		new PrintWriter (new BufferedOutputStream (new FileOutputStream (outputFile)));
 	    fileout.write (data);
 	    fileout.close();
 	} catch (IOException e) {
 	    throw new MobyException ("Cannot write to '" + outputFile.getAbsolutePath() + ". " + e.toString());
+	} finally {
+	    if (fileout != null)
+		fileout.close();
 	}
     }
 
@@ -343,9 +347,10 @@
      *************************************************************************/
     protected static String load (File file)
 	throws MobyException {
+	BufferedReader in = null;
 	try {
 	    StringBuffer buf = new StringBuffer();
-	    BufferedReader in
+	    in
 		= new BufferedReader (new FileReader (file));
 	    char[] buffer = new char[1024];
 	    int charsRead;
@@ -359,6 +364,11 @@
 	} catch (Throwable e) {     // be prepare for "out-of-memory" error
 	    throw new MobyException ("Serious error when reading from cache. " + e.toString());
 
+	} finally {
+	    if (in != null)
+		try {
+		    in.close();
+		} catch (IOException e) {}
 	}
     }
 




More information about the MOBY-guts mailing list