[tranche] r280 committed - Safe close methods in IOUtil for disk-backed collections

3 views
Skip to first unread message

tra...@googlecode.com

unread,
Jul 1, 2010, 12:38:15 PM7/1/10
to tranche-d...@googlegroups.com
Revision: 280
Author: bryanesmith
Date: Thu Jul 1 09:37:28 2010
Log: Safe close methods in IOUtil for disk-backed collections
http://code.google.com/p/tranche/source/detail?r=280

Modified:
/src/org/tranche/util/IOUtil.java

=======================================
--- /src/org/tranche/util/IOUtil.java Tue Mar 9 14:35:47 2010
+++ /src/org/tranche/util/IOUtil.java Thu Jul 1 09:37:28 2010
@@ -48,6 +48,8 @@
import org.tranche.exceptions.AssertionFailedException;
import org.tranche.flatfile.DataBlockUtil;
import org.tranche.flatfile.FlatFileTrancheServer;
+import org.tranche.hash.DiskBackedBigHashList;
+import org.tranche.hash.DiskBackedBigHashSet;
import org.tranche.project.ProjectFile;
import org.tranche.remote.RemoteTrancheServer;
import org.tranche.server.PropagationReturnWrapper;
@@ -284,6 +286,30 @@
}
}
}
+
+ /**
+ * <p>Helper method to safely close disk-backed colletion.</p>
+ * @param list
+ */
+ public static final void safeClose(DiskBackedBigHashSet set) {
+ if (set != null) {
+ try {
+ set.close();
+ } catch (Exception nope) {}
+ }
+ }
+
+ /**
+ * <p>Helper method to safely close disk-backed colletion.</p>
+ * @param list
+ */
+ public static final void safeClose(DiskBackedBigHashList list) {
+ if (list != null) {
+ try {
+ list.close();
+ } catch (Exception nope) {}
+ }
+ }

/**
* <p>Helper method to make sure that the DFS closes and that no
exceptions are thrown, including NullPointerExceptions.</p>

Reply all
Reply to author
Forward
0 new messages