Author: nextgens
Date: 2008-02-26 08:27:43 +0000 (Tue, 26 Feb 2008)
New Revision: 18161
Modified:
trunk/freenet/src/freenet/support/LibraryLoader.java
trunk/freenet/src/net/i2p/util/NativeBigInteger.java
Log:
Fix one of the temporary file leacks
Modified: trunk/freenet/src/freenet/support/LibraryLoader.java
===================================================================
--- trunk/freenet/src/freenet/support/LibraryLoader.java 2008-02-26
08:09:13 UTC (rev 18160)
+++ trunk/freenet/src/freenet/support/LibraryLoader.java 2008-02-26
08:27:43 UTC (rev 18161)
@@ -13,6 +13,8 @@
* A simple class to load native libraries from the -ext jarfile
*
* @author Florent Daignière <nextgens at freenetproject.org>
+ *
+ * TODO: make it more generic so that all libraries can use it (bigint,
jcpuid, fec, ...)
*/
public class LibraryLoader {
Modified: trunk/freenet/src/net/i2p/util/NativeBigInteger.java
===================================================================
--- trunk/freenet/src/net/i2p/util/NativeBigInteger.java 2008-02-26
08:09:13 UTC (rev 18160)
+++ trunk/freenet/src/net/i2p/util/NativeBigInteger.java 2008-02-26
08:27:43 UTC (rev 18161)
@@ -525,16 +525,20 @@
System.err.println("NOTICE: Resource name [" +
getResourceName(true) + "] was not found");
return false;
}
-
+ File temp = null;
try {
try {
- if(tryLoadResource(File.createTempFile("jbigi",
"lib.tmp"), resource))
+ temp = File.createTempFile("jbigi", "lib.tmp");
+ if(tryLoadResource(temp, resource))
return true;
} catch(IOException e) {
+ } finally {
+ if(temp != null) temp.delete();
}
Logger.error(NativeBigInteger.class, "Can't load from "
+ System.getProperty("java.io.tmpdir"));
System.err.println("Can't load from " +
System.getProperty("java.io.tmpdir"));
- if(tryLoadResource(new File("jbigi-lib.tmp"), resource))
+ temp = new File("jbigi-lib.tmp");
+ if(tryLoadResource(temp, resource))
return true;
} catch(Exception fnf) {
Logger.error(NativeBigInteger.class, "Error reading
jbigi resource");
@@ -542,6 +546,8 @@
} catch(UnsatisfiedLinkError ule) {
Logger.error(NativeBigInteger.class, "Library " +
resourceName + " is not appropriate for this system.");
System.err.println("Library " + resourceName + " is not
appropriate for this system.");
+ } finally {
+ if(temp != null) temp.delete();
}
return false;