提交 a14c8363 编写于 作者: K kohsuke

early disposal for better GC

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@12952 71c3de6d-444a-0410-be80-ed276b4c234a
上级 1e2c2e14
......@@ -17,18 +17,22 @@ public class DotNet {
// observation in my registry shows that the actual key name can be things like "v2.0 SP1"
// or "v2.0.50727", so the regexp is written to accomodate this.
RegistryKey key = RegistryKey.LOCAL_MACHINE.openReadonly("SOFTWARE\\Microsoft\\.NETFramework");
for( String keyName : key.getSubKeys() ) {
Matcher m = VERSION_PATTERN.matcher(keyName);
if(m.matches()) {
int mj = Integer.parseInt(m.group(1));
if(mj>=major) {
int mn = Integer.parseInt(m.group(2));
if(mn>=minor)
return true;
try {
for( String keyName : key.getSubKeys() ) {
Matcher m = VERSION_PATTERN.matcher(keyName);
if(m.matches()) {
int mj = Integer.parseInt(m.group(1));
if(mj>=major) {
int mn = Integer.parseInt(m.group(2));
if(mn>=minor)
return true;
}
}
}
return false;
} finally {
key.dispose();
}
return false;
}
private static final Pattern VERSION_PATTERN = Pattern.compile("v(\\d+)\\.(\\d+).*");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册