提交 7a59355c 编写于 作者: K kohsuke

[HUDSON-3933] Added a null check so that we can at least see the error message...

[HUDSON-3933] Added a null check so that we can at least see the error message to identify what file is causing this.

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@19569 71c3de6d-444a-0410-be80-ed276b4c234a
上级 3b93eefd
......@@ -131,20 +131,22 @@ public class Which {
if (con instanceof JarURLConnection) {
JarURLConnection jcon = (JarURLConnection) con;
JarFile jarFile = jcon.getJarFile();
String n = jarFile.getName();
if(n.length()>0) {// JDK6u10 needs this
return new File(n);
} else {
// JDK6u10 apparently starts hiding the real jar file name,
// so this just keeps getting tricker and trickier...
try {
Field f = ZipFile.class.getDeclaredField("name");
f.setAccessible(true);
return new File((String) f.get(jarFile));
} catch (NoSuchFieldException e) {
LOGGER.log(Level.INFO, "Failed to obtain the local cache file name of "+clazz, e);
} catch (IllegalAccessException e) {
LOGGER.log(Level.INFO, "Failed to obtain the local cache file name of "+clazz, e);
if (jarFile!=null) {
String n = jarFile.getName();
if(n.length()>0) {// JDK6u10 needs this
return new File(n);
} else {
// JDK6u10 apparently starts hiding the real jar file name,
// so this just keeps getting tricker and trickier...
try {
Field f = ZipFile.class.getDeclaredField("name");
f.setAccessible(true);
return new File((String) f.get(jarFile));
} catch (NoSuchFieldException e) {
LOGGER.log(Level.INFO, "Failed to obtain the local cache file name of "+clazz, e);
} catch (IllegalAccessException e) {
LOGGER.log(Level.INFO, "Failed to obtain the local cache file name of "+clazz, e);
}
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册