* Avoid leaking FD in Natives.computeNativesHash()

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10774 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
experimental
sha..RD 12 years ago
parent e66abb780d
commit 610d6e47fc
  1. 12
      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.

Loading…
Cancel
Save