提交 6d8271da 编写于 作者: K kohsuke

[FIXED HUDSON-2831] Added handling for vfszip:/ protocol handler for JBoss5....

[FIXED HUDSON-2831] Added handling for vfszip:/ protocol handler for JBoss5. This is ugly hack, but this was the best I was able to come up with. 


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@14857 71c3de6d-444a-0410-be80-ed276b4c234a
上级 246d070b
......@@ -9,6 +9,8 @@ import java.net.URL;
import java.net.MalformedURLException;
import java.net.URLConnection;
import java.net.JarURLConnection;
import java.lang.reflect.Field;
import java.util.zip.ZipFile;
/**
* Locates where a given class is loaded from.
......@@ -74,6 +76,27 @@ public class Which {
return new File(decode(new URL(resURL).getPath()));
}
if(resURL.startsWith("vfszip:")) {
// JBoss5
InputStream is = res.openStream();
try {
Field f = is.getClass().getDeclaredField("delegate");
f.setAccessible(true);
Object delegate = f.get(is);
f = delegate.getClass().getDeclaredField("this$0");
f.setAccessible(true);
ZipFile zipFile = (ZipFile)f.get(delegate);
return new File(zipFile.getName());
} catch (NoSuchFieldException e) {
// something must have changed in JBoss5. fall through
} catch (IllegalAccessException e) {
// something must have changed in JBoss5. fall through
} finally {
is.close();
}
}
URLConnection con = res.openConnection();
if (con instanceof JarURLConnection) {
JarURLConnection jcon = (JarURLConnection) con;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册