瀏覽代碼

* Avoid leaking FD in Natives.computeNativesHash()

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10774 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
sha..RD 12 年之前
父節點
當前提交
610d6e47fc
共有 1 個文件被更改,包括 10 次插入2 次删除
  1. 10 2
      engine/src/desktop/com/jme3/system/Natives.java

+ 10 - 2
engine/src/desktop/com/jme3/system/Natives.java

@@ -85,6 +85,7 @@ public final class Natives {
     }
 
     private static int computeNativesHash() {
+        URLConnection conn = null;
         try {
             String classpath = System.getProperty("java.class.path");
             URL url = Thread.currentThread().getContextClassLoader().getResource("com/jme3/system/Natives.class");
@@ -101,11 +102,18 @@ public final class Natives {
                 throw new UnsupportedOperationException(ex);
             }
 
-            URLConnection conn = url.openConnection();
+            conn = url.openConnection();
             int hash = classpath.hashCode() ^ (int) conn.getLastModified();
             return hash;
         } catch (IOException ex) {
             throw new UnsupportedOperationException(ex);
+        } finally {
+            if (conn != null) {
+                try {
+                    conn.getInputStream().close();
+                    conn.getOutputStream().close();
+                } catch (IOException ex) { }
+            }
         }
     }
 
@@ -233,7 +241,7 @@ public final class Natives {
 
         String libraryPath = getExtractionDir().toString();
         if (needLWJGL) {
-            logger.log(Level.FINE, "Extraction Directory: {0}", getExtractionDir().toString());
+            logger.log(Level.INFO, "Extraction Directory: {0}", getExtractionDir().toString());
 
             // LWJGL supports this feature where
             // it can load libraries from this path.