Skip to content

Commit

Permalink
[JENKINS-37566] - JBoss magic should really fail if we cannot mark fi…
Browse files Browse the repository at this point in the history
…elds as accessible
  • Loading branch information
oleg-nenashev committed Oct 25, 2016
1 parent 408bc16 commit 574a815
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions src/main/java/hudson/remoting/Which.java
Expand Up @@ -144,26 +144,21 @@ public static File jarFile(Class clazz) throws IOException {
Object delegate = is;
while (delegate.getClass().getEnclosingClass()!=ZipFile.class) {
Field f = delegate.getClass().getDeclaredField("delegate");
if (!ReflectionUtils.makeAccessibleOrLog(f, LOGGER, Level.FINE)) {
continue;
}
ReflectionUtils.makeAccessible(f);

delegate = f.get(delegate);
//JENKINS-5922 - workaround for CertificateReaderInputStream; JBoss 5.0.0, EAP 5.0 and EAP 5.1
if(delegate.getClass().getName().equals("java.util.jar.JarVerifier$VerifierStream")){
f = delegate.getClass().getDeclaredField("is");
if (!ReflectionUtils.makeAccessibleOrLog(f, LOGGER, Level.FINE)) {
continue;
}
ReflectionUtils.makeAccessible(f);
delegate = f.get(delegate);
}
}
Field f = delegate.getClass().getDeclaredField("this$0");
if (ReflectionUtils.makeAccessibleOrLog(f, LOGGER, Level.FINE)) {
ZipFile zipFile = (ZipFile)f.get(delegate);
return new File(zipFile.getName());
} // Else fall through till alternative actions or exception
} catch (NoSuchFieldException e) {
ReflectionUtils.makeAccessible(f);
ZipFile zipFile = (ZipFile)f.get(delegate);
return new File(zipFile.getName());
} catch (NoSuchFieldException | PrivilegedActionException e) {
// something must have changed in JBoss5. fall through
LOGGER.log(Level.FINE, "Failed to resolve vfszip into a jar location",e);
} catch (IllegalAccessException e) {
Expand Down

0 comments on commit 574a815

Please sign in to comment.